From Gentoo Wiki
Jump to: navigation, search
This page contains changes which are not marked for translation.

External resources

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


If you want to install Vim with both the ncurses-based interface for the terminal (/usr/bin/vim) and the graphical interface for X (/usr/bin/gvim), just type:

root # emerge --ask app-editors/gvim

If you are only interested in using Vim in a terminal, type:

root # emerge --ask app-editors/vim

There is also an experimental Qt interface called vim-qt, available in the qt overlay.


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

root # emerge --search "%@^app-vim"


user $ eix -cC app-vim

Getting started

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

user $ vimtutor


Vim has 3 modes:

  • Command mode: Keystrokes are interpreted as commands
  • Insert mode: Keystrokes are interpreted as text (except a few special commands)
  • Visual mode: Visual mode supports you by selecting some text. It behaves a lot like command mode

Tips and Tricks

Using Vim like ex or ed from the command line

Add '#' to begin of each line of file.txt:

user $ vim -c ":%s/^/#/g" -c ":x" file.txt

From vim command mode:

: %s/^/#/g

Change file encoding

Change encoding of file to UTF-8:

user $ vim -c ":wq! ++enc=utf8" file.txt

Reload file in UTF-8 from vim command mode:

: e ++enc=utf8

More resources

On this wiki

External resources