vi Editor

The vi editor comes standard on all Unix-like operating systems, and is a hell of an editor besides that! The learning curve is high, the editing paradigm is different from other editors. However, once you accept the “vi” lifestyle, there is no going back!

An open-source version if vi called VIM (Vi IMproved) is available on Linux and other GNU-software distributions. It rocks. Here, I present a quick introduction and reference to the standard vi editor.

vi modes

The vi editor has a few different modes used to communicate from the keyboard.

  • Input Mode: is entered my a command keystroke, then you type the text into the file, and press ESCape to exit input mode. You can tell a typical vi user in that the ESCape key letters are almost worn completely off!
  • Command Mode: is entered by entering: repition+command+target, where the optional repition is a number, command is a keystroke command, and target is a regular expression, or short-cut target. These command can be used to position the cursor, scroll, or manipulate the contents. The default target on commands is the same as the command keystroke: when ‘d’ is the delete command, ‘dd’ deletes the current line. Sometimes even that gets the capital letter (well, not ‘D’ in this case).
  • EX mode: Allow you to enter EX style commands (an older line-editor) for the file. These are started by the colon (:) keystroke followed by the command. After you enter the command, you return to Command mode.

targets

ActionCommand
Until text formward / backward /regular_expression ?regular_expression
Start / First Char / End of Line 0 ^ $
End of File G
Top / Middle / Bottom of screen H M L
Up / Down / Left / Right k j h k
Scroll up line / half / full Ctrl+y Ctrl+u Ctrl+b
Scroll down line / half / full Ctrl+e Ctrl+d Ctrl+f
Goto line (target)
Goto char(x), backwards fx Fx
Repeat search, reverse search, char search n N ;
Column n n
Mark line as position x mx
Return to marked postion x `x
Word skipping forward, backward w b

Input and Manipulation Commands

Append after char/line a A
Insert after/prepend line i I
Replace character/Text r R
Change (target) / change End of line c target C
Insert line after / above o O
Repeat / Undo last change . u
Reverse case ~
Delete line / delete (target) dd / d target
Shift Left (line/Target) / Right « / > / >target

Cutting (Yanking) and Pasting

Copy line / target to buffer Y / y target
Cutting text See “delete”
Paste buffer p
 
computing/vim.txt · Last modified: 2005/07/18 12:14