How to install vim on CentOS 8 using dnf/yum

last updated in Categories , ,

I like VIM text editor a lot, and it is missing on my CentOS 8 box. How do I install vim on CentOS 8 Linux cloud server?

This page explains how to install VIM text editor on CentOS 8 Linux server or desktop using the dnf command/yum command.
Tutorial requirements
Operating system/appCentOS 8 Linux
Root privileges requiredYes
DifficultyEasy (rss)
Estimated completion time2m
Table of contents

ADVERTISEMENTS


How to install vim on CentOS 8

VIM means Vi IMproved and often called as a programmer’s text editor. VIM is popular among sysadmins, DevOps engineers, Linux enthusiasts, and users. By default, CentOS 8 minimal version ships with a simple version of vi to keep cloud images small. However, we can search and install VIM as follows.

Step 1: Search for vim packages

Open the terminal app and then enter the following command. We can search vim package using metadata for keywords. The syntax is as follows:
$ sudo dnf search vim
Here is what I get on my box:

Last metadata expiration check: 0:15:25 ago on Wednesday 13 May 2020 02:22:40 PM IST.
================================== Name & Summary Matched: vim ===================================
vim-gv.noarch : Git commit browser in Vim
vim-filesystem.noarch : VIM filesystem layout
geany-plugins-vimode.x86_64 : Vim-mode plugin for Geany
vim-minimal.x86_64 : A minimal version of the VIM editor
vim-minimal.x86_64 : A minimal version of the VIM editor
vim-devicons.noarch : Adds file type icons to Vim plugins
fluxbox-vim-syntax.noarch : Fluxbox syntax scripts for vim
vim-jellybeans.noarch : A colorful, dark color scheme for Vim
vim-airline.noarch : Lean & mean status/tabline for vim that's light as air
vim-common.x86_64 : The common files needed by any version of the VIM editor
vim-X11.x86_64 : The VIM version of the vi editor for the X Window System - GVim
vim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancements
awesome-vim-colorschemes.noarch : Collection of color schemes for Neo/vim, merged for quick use
======================================= Name Matched: vim ========================================
vim-pathogen.noarch : Manage your runtimepath
vim-gitgutter.noarch : Shows a git diff in the gutter and stages/undoes hunks and partial hunks
vim-nerdtree-git-plugin.noarch : Plugin of NERDTree showing git status
====================================== Summary Matched: vim ======================================
kakoune.x86_64 : Code editor heavily inspired by Vim

Another useful command is as follows:
$ sudo dnf list vim\*

Step 2: Getting info about vim package on CentOS 8

We got a vim-minimal installed. What we need is vim-enhanced. Let us find out the difference between the two by typing the following simple commands:
$ sudo dnf info vim-minimal
$ sudo dnf info vim-enhanced

Outputs:

Last metadata expiration check: 0:18:53 ago on Wednesday 13 May 2020 02:22:40 PM IST.
Available Packages
Name         : vim-enhanced
Epoch        : 2
Version      : 8.0.1763
Release      : 13.el8
Architecture : x86_64
Size         : 1.4 M
Source       : vim-8.0.1763-13.el8.src.rpm
Repository   : AppStream
Summary      : A version of the VIM editor which includes recent enhancements
URL          : http://www.vim.org/
License      : Vim and MIT
Description  : VIM (VIsual editor iMproved) is an updated and improved version of the
             : vi editor.  Vi was the first real screen-based editor for UNIX, and is
             : still very popular.  VIM improves on vi by adding new features:
             : multiple windows, multi-level undo, block highlighting and more.  The
             : vim-enhanced package contains a version of VIM with extra, recently
             : introduced features like Python and Perl interpreters.
             : 
             : Install the vim-enhanced package if you'd like to use a version of the
             : VIM editor which includes recently added enhancements like
             : interpreters for the Python and Perl scripting languages.  You'll also
             : need to install the vim-common package.

Step 3: Installing vim-enhanced on CentOS Linux 8 server

Execute the following dnf command/yum command:
$ sudo dnf install vim-enhanced
## OR ##
$ sudo yum install vim-enhanced

How to install VIM on CentOS 8 Linux server or desktop

Step 4: Start using vim

The syntax is:
$ vim filename
$ vim /path/to/file
$ vim [options] my-code.sh

We can create a permanent Bash alias:
$ alias vi='vim'
Add bash shell aliases to ~/.bashrc or ~/.bash_aliases file:
$ echo "alias vi='vim'" >> ~/.bashrc
Reload it:
$ source ~/.bashrc
We can also set vim as the system wide default text editor on CentOS 8 as follows:
$ sudo -i
# echo 'export VISUAL="vim"' > /etc/profile.d/vimeditor.sh
# echo 'export EDITOR="vim"' >> /etc/profile.d/vimeditor.sh

The Vim tutor

Are you new to VIM? Do you want to learn Vim commands? No need to search the Internet or book. VIM comes with the Vim tutor. All you have to do is type the following command:
$ vimtutor
The optional [language] argument is the two-letter name of a language, like “it” or “es”. To list installed languages, run the following ls command
$ ls -l /usr/share/vim/vim*/tutor/
Sample listing:

README.el.cp737.txt  tutor.el         tutor.hu.utf-8  tutor.no.utf-8   tutor.sv
README.el.txt        tutor.el.cp737   tutor.it        tutor.pl         tutor.sv.utf-8
README.txt           tutor.el.utf-8   tutor.it.utf-8  tutor.pl.cp1250  tutor.tr.iso9
tutor                tutor.eo         tutor.ja.euc    tutor.pl.utf-8   tutor.tr.utf-8
tutor.bar            tutor.eo.utf-8   tutor.ja.sjis   tutor.pt         tutor.uk.utf-8
tutor.bar.utf-8      tutor.es         tutor.ja.utf-8  tutor.pt.utf-8   tutor.utf-8
tutor.bg.utf-8       tutor.es.utf-8   tutor.ko.euc    tutor.ru         tutor.vim
tutor.ca             tutor.fr         tutor.ko.utf-8  tutor.ru.cp1251  tutor.vi.utf-8
tutor.ca.utf-8       tutor.fr.utf-8   tutor.lv        tutor.ru.utf-8   tutor.zh.big5
tutor.cs             tutor.hr         tutor.nb        tutor.sk         tutor.zh_cn.utf-8
tutor.cs.cp1250      tutor.hr.cp1250  tutor.nb.utf-8  tutor.sk.cp1250  tutor.zh.euc
tutor.cs.utf-8       tutor.hr.utf-8   tutor.nl        tutor.sk.utf-8   tutor.zh_tw.utf-8
tutor.de             tutor.hu         tutor.nl.utf-8  tutor.sr.cp1250  tutor.zh.utf-8
tutor.de.utf-8       tutor.hu.cp1250  tutor.no        tutor.sr.utf-8

Hence, I can type:
$ vimtutor es
$ vimtutor lv
$ vimtutor tr
$ vimtutor it

Conclusion

In this tutorial, we learned how to install VIM (VIsual editor iMproved) is an updated and improved version of the vi editor on CentOS 8. Vi was the first real screen-based editor for UNIX, and is still very popular. VIM improves on vi by adding new features multiple windows, multi-level undo, block highlighting, and more. The vim-minimal package includes a minimal version of VIM, which is installed into /bin/vi for use when only the root partition is present. Hence, we must install vim-enhanced to get a full-fledged editor. See VIM official page here.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.


ADVERTISEMENTS

Leave a Comment