Vim is a clone of the vi text editor. Vim provides a lot of improvement over the vi. Vim is created in 1991 and licensed as an open-source Vim License. Even vi is installed in most of the popular Linux distributions as well as Ubuntu by default Vim is not installed by default. So you will install Vim Ubuntu by following these steps.
Search Vim Package
Even it is not required to install Vim we will search for the Vim packages. Most of the distributions provide a lot of Vim and related packages even a different version of Vim. First, we will update the package repository with the following command.
$ sudo apt update
Then we will use the following command in order to search the Vim package.
$ apt search vim
We can see that there are very different packages related to the Vim from the output. The package name we ware looking for is the
vim . From the explanation, we see that this package is described as “Vi IMproved – enhanced vi editor”. This is because Vim is an enhanced version of the old Vi text editor. If you want to use the Vi editor you can also install Vim too.
Show Vim Package Information
The package information about Vim contains the version of the Vim, package name, installed size, download size, etc.
$ apt show vim
The output will be like below.
Package: vim Version: 2:8.1.2269-1ubuntu5 Priority: optional Section: editors Origin: Ubuntu Maintainer: Ubuntu Developers firstname.lastname@example.org Original-Maintainer: Debian Vim Maintainers email@example.com Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 3,111 kB Provides: editor Depends: vim-common (= 2:8.1.2269-1ubuntu5), vim-runtime (= 2:8.1.2269-1ubuntu5), libacl1 (>= 2.2.23), libc6 (>= 2.29), libcanberra0 (>= 0.2), libgpm2 (>= 1.20.7), libpython3.8 (>= 3.8.2), libselinux1 (>= 1.32), libtinfo6 (>= 6) Suggests: ctags, vim-doc, vim-scripts Homepage: https://www.vim.org/ Task: server, cloud-image, lubuntu-desktop Download-Size: 1,238 kB APT-Manual-Installed: yes APT-Sources: http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages Description: Vi IMproved - enhanced vi editor Vim is an almost compatible version of the UNIX editor Vi. . Many new features have been added: multi level undo, syntax highlighting, command line history, on-line help, filename completion, block operations, folding, Unicode support, etc. . This package contains a version of vim compiled with a rather standard set of features. This package does not provide a GUI version of Vim. See the other vim-* packages if you need more (or less).
We will install the Vim with the following apt command. We will also provide the package name for the vim. We will also use the sudo command in order to provide the root privilege.
$ sudo apt install vim
Alternatively, you can use the apt-get command which provides the same functionality and parameters as the apt command.
$ sudo apt-get install vim
Check Vim Version
After the Vim is installed we can check the installed Vim version. We will use the –version parameter. Normally, the vim command opens the Vim text editor but by using the –version parameter the Vim editor will not be opened.
$ vim --version
The output will be like below which contains information like version, developers, features, compile options, etc.
VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 15 2020 06:40:31) Included patches: 1-2269 Modified by firstname.lastname@example.org Compiled by email@example.com Huge version without GUI. Features included (+) or not (-): +acl -farsi -mouse_sysmouse -tag_any_white +arabic +file_in_path +mouse_urxvt -tcl +autocmd +find_in_path +mouse_xterm +termguicolors +autochdir +float +multi_byte +terminal -autoservername +folding +multi_lang +terminfo -balloon_eval -footer -mzscheme +termresponse +balloon_eval_term +fork() +netbeans_intg +textobjects -browse +gettext +num64 +textprop ++builtin_terms -hangul_input +packages +timers +byte_offset +iconv +path_extra +title +channel +insert_expand -perl -toolbar +cindent +job +persistent_undo +user_commands -clientserver +jumplist +postscript +vartabs -clipboard +keymap +printer +vertsplit +cmdline_compl +lambda +profile +virtualedit +cmdline_hist +langmap -python +visual +cmdline_info +libcall +python3 +visualextra +comments +linebreak +quickfix +viminfo +conceal +lispindent +reltime +vreplace +cryptv +listcmds +rightleft +wildignore +cscope +localmap -ruby +wildmenu +cursorbind -lua +scrollbind +windows +cursorshape +menu +signs +writebackup +dialog_con +mksession +smartindent -X11 +diff +modify_fname +sound -xfontset +digraphs +mouse +spell -xim -dnd -mouseshape +startuptime -xpm -ebcdic +mouse_dec +statusline -xsmp +emacs_tags +mouse_gpm -sun_workshop -xterm_clipboard +eval -mouse_jsbterm +syntax -xterm_save +ex_extra +mouse_netterm +tag_binary +extra_search +mouse_sgr -tag_old_static system vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" 2nd user vimrc file: "~/.vim/vimrc" user exrc file: "$HOME/.exrc" defaults file: "$VIMRUNTIME/defaults.vim" fall-back for $VIM: "/usr/share/vim" Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -Wdate-time -g -O2 -fdebug-prefix-map=/build/vim-iU6mZD/vim-8.1.2269=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 Linking: gcc -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lm -ltinfo -lnsl -lselinux -lcanberra -lacl -lattr -lgpm -ldl -L/usr/lib/python3.8/config-3.8-x86_64-linux-gnu -lpython3.8 -lcrypt -lpthread -ldl -lutil -lm -lm
Install Vim Plugins and Vim Related Packages
As an advanced text editor, Vim/Vi provides a lot of plugins and related feature packages. We can install them to enrich Vim/Vi. We can search these plugins and related packages with the following
apt search command.
$ apt search vim
In this case, we install the
vim-python-jedi which is an autocompletion tool for Python.
$ sudo apt install vim-python-jedi
Install Vim/Vi GUI
The vim/Vi is mainly used in the command line interface but they can be also used with a GUI. The GUI provides the same functionality as some GUI menus. The Vim/Vi GUI can be installed by using the
$ sudo apt install vim-gtk3