Vi

From Pandora Wiki
Jump to: navigation, search

vi is a text editor that has two modes, there is the insert mode and then command mode. In insert mode, you can enter text and it will act like a normal text editor. In command mode, it will do functions like cut, copy, paste, search, save, quit, etc. It's a powerful little editor that is installed by default on almost any Linux distribution. It's also great for writing code. vi is on Included Package List Here's a couple of hints on using vi (or vim):

from the command line to open the file in vi:

vi <filename>
Command Description
i insert mode, needed to start putting text into your file
[esc] escape, stops insert mode or other action
/<search term> search through your file for a search term
n find next match
N find previous match
yy copy line
2yy copy two lines
p paste (line or other)
dd cut line (p will paste it)
x cut character (use this instead of backspace!)
10x cut ten characters
:w write/save
:w <new name> save as <new name>
:q quit
:q! quit without making any changes
:wq write, then quit
k up (when not in edit mode)
j down
h left
l right
b jump to beginning of word
e jump to end of word
gg jump to top of file
:23 jump to line 23 of file


By default there is no vi/vim config file shipped. This means that vim (in fact you are using vim, not plain vi) does work in vi compatibility mode. This makes life harder by not allowing to use the dpad (arrow keys on a normal keyboard). Copy the attached file in this bugreport to ~/.vimrc to get a rather decent default config.

Personal tools
community