Tuesday, May 23, 2006

Common VI Commands used

To move to a log at the end of the file:


^f move forward one screen

^b move backward one screen

^d move down (forward) one half screen

^u move up (back) one half screen

* u UNDO WHATEVER YOU JUST DID; a simple toggle

* a append text after cursor, until hit
* i insert text before cursor, until hit

* r replace single character under cursor (no needed)

R replace characters, starting with current cursor position, until hit

* x delete single character under cursor

Nx delete N characters, starting with character under cursor
* dd delete entire current line

Ndd or dNd delete N lines, beginning with the current line;
e.g., 5dd deletes 5 lines


yy copy (yank, cut) the current line into the buffer

Nyy or yNy copy (yank, cut) the next N lines, including the current line, into the buffer

p put (paste) the line(s) in the buffer into the text after the current line


/string search forward for occurrence of string in text

?string search backward for occurrence of string in text

n move to next occurrence of search string

N move to next occurrence of search string in opposite direction

MOVING

:# move to line #

:$ move to last line of file

No comments: