Table of Contents

vi tips

I'm using vim instead of vi.

Scripts

Helpful addon scripts to vim

These script files should reside in ~/.vim/plugin:

[john@bender ~]$ mkdir -p .vim/{plugin,doc}
[john@bender ~]$ ls .vim/
doc  plugin

rcs.vim

rcs.vim project page

This script allows you to manage rcs files automatically:

Information

vim visual mode explanation


Indent Multiple lines: 1)

The << and >> commands are used to for block indenting.
The >> indents a line right one tab and << indents a line left 
one tab. You can indent a whole bunch of lines by giving a number
the number before the >> or <<. For example, 10>> will indent
ten lines from the current cursor position.

Syntax

vi/vim syntax 2) 3)

switch to insert/edit mode
command description verified command?
i insert text at cursor yes
o insert new line below cursor yes
a insert text after cursor yes
I Insert text at the beginning of the line yes
O Open line above cursor yes
A Append text at the end of the line yes
switch to command mode
<ESC> switch to command mode (stop editing) yes
cursor movement (command mode)
<CTRL> + b page up 1 screen yes
<CTRL> + u page up 1/2 screen yes
<CTRL> + d page down 1/2 screen yes
<CTRL> + f page down 1 screen yes
G go to last line yes
:n or nG go to line n yes
0 (zero) go to beginning of line yes
$ go to end of line yes
( ) scroll by sentence (f/b) yes
w b scroll by word (f/b) yes
h j k l move left, down, up, right yes
nx move xn characters/lines where x is (h, j, k, or l) yes
Arrow Keys directional movement yes
:set number show line numbers yes
:set nonumber hide line numbers yes
Deleting text (command mode)
cw change word at cursor yes
dw delete word at cursor yes
r replace one character yes
x delete text at cursor yes
D delete current to end of line yes
dd delete entire line yes
ndd delete n lines yes
:m,nd delete lines m-n yes
Editing (command mode)
yy copy line no
nyy copy n lines no
:m,nt o copy lines m-n, paste after o no
P paste above current line no
p paste below current line no
:m,nm o cut lines m-n, paste after o no
J join previous line no
?string search backward for string yes
/string search forward for string yes
:set paste enable paste mode, which pastes without auto-formatting yes
:set nopaste disable paste mode (re-enable auto-format) yes
View Modes new for vim version 7.0 4)
:tabnew filename open filename in a new “tab” no