Vim

Vim (Vi improved) is Article description::a text editor based on the text editor. It can be used from the command-line or as a standalone application with a graphical user interface.

Vim should not be confused with Neovim, a similar program which may be used in its place.

Emerge
If X Window System support is not needed, install :

Gvim
To install Vim with both the ncurses-based interface as well as the graphical interface (for the X Window System - ), install the  package:

Packages
Vim has support for packages, which provide a native mechanism to extend functionality. Read the built-in packages documentation for more information:

Plugins
The category provides a lot of additional syntax definitions, plugins and other Vim related stuff.

Use or  to get an overview of available packages in the  category:

Not all Vim plugins will be available in the Gentoo repository. Vim now includes native packages, as a way to install plugins, and there are also several plugin managers for Vim.

Files
Vim can be configured on a per-user basis or through a system-wide configuration file:


 * - The system wide (global) settings file.
 * - The user-specific (local) configuration file. The tilde (~) means it is in the user's home directory.
 * - Location where plugins are installed (vim 8 and higher). Substitute for the name of each plugin.

Color schemes
About a dozen color schemes are shipped with the base Vim package. They can be listed in last line mode by typing colorscheme, then pressing either + or pressing the key twice:

They can be changed in Vim by using the (alternatively use ) command while in last line mode:

Color schemes can be permanently applied in the file:

The first line sets the default color scheme while the last line activates the color scheme.

Selecting vi editor and system default editor
If Vim - and only Vim - is installed, the command should launch Vim. If other vi-like editors are installed, eselect may be used to choose which editor the command launches.

The text editor article may also be of interest for setting a system default editor, if Vim is to be set as the default.

Invocation
From the command line:

The command may also be used to launch Vim, if so configured.

Specify a name, to open an existing file, or to create a new one:

Tutorial
Vim has a built-in tutorial which should require around 30 minutes to go through. Start it using the command:

Using Vim like ex or ed from the command line
It is possible to use Vim for one-liners — commands that can be used in scripts or on the command-line to make changes in an unattended manner.

For instance, the following command adds  to the beginning of each line in the  file:

What happens is that Vim interprets the passed on commands (through the  option). The first command is Vim's substitution command (which is very similar to 's), the second one is Vim's instruction to save and exit the editor.

Change file encoding
To change the file encoding of a file to UTF-8, use the following command (in last line mode):

As shown in the previous trick, it is possible to do this from the command line as well:

I'm trapped in vim!
For someone entering vim without knowing how to use it, it may not be evident how to quit.

Press several times, then, ,. To quit without saving, press several times, then, , ,.

If several files are open, try pressing several times, then, , ,. To quit without saving, press several times, then, , , ,.

If this doesn't help, and desperate measures are needed, something like may be a last ditch solution (from another terminal). Beware that this will terminate all the vim sessions for a user, without saving. If run as root, such a command will terminate all vim sessions for all users on the system.

External resources

 * Vim Documentation Includes Manuals (aka ":help" and Free VIM OPL Book), FAQS, HOWTO's, Tutorials, in HTML PDF, and PS formats.
 * A vim Tutorial and Primer - An excellent vim tutorial/primer. Read this first.
 * VIM Scripts/Plugins
 * Vim for Humans (free ebook) - Clone and into the sources directory,, change   to   for SPHINXBUILD in . Run . Read PDF in.
 * Learning the vi and Vim Editors, 7th Edition O'Reilly  Print ISBN: 978-0-596-52983-3, Ebook ISBN: 978-0-596-15935-1
 * Vim anti-patterns - A blog entry on maintaining flow with Vim.
 * Vim Tips Wiki - Previously known as Wikia, Vim Tips Wiki is now on Fandom.com.