Thursday, January 22, 2009

vi commands

Switch to command mode

ESC start command mode ( it starts in command mode )
i change to insert mode
:q quit
:wq write and quit
:w write the file
:# goto line #
/str search down for "str"
?str search up for "str"
dd delete line
x delete character
dw delete word ( cut )
yy yank line ( copy )
yw yank word
p paste
u undo ( only limit is the last write )
. repeat last change
cw change word

Go to line number ## :##

Undo previous command: u

Undo all changes to line: U

Search backward for string: ?string

Search forward for string: /string

% (entire file) s (search and replace) /old text with new/ c (confirm) g (global - all): %s/oldstring/newstring/cg

Delete 5 lines (to buffer): 5dd

Delete lines 5-10:5,10d

No comments: