|
Here we are listing some common VI Commands...
vi is a visual editor for editing text files. It is not a word processor. vi is most commonly used for programming. The following is a list of some basic vi commands. All of the following commands can only be used from command mode. When you first start vi, you are in command mode. If you are ever unsure which mode your in, hit <esc> and you will be in command mode for sure.
| i |
|
insert text at cursor
|
| a |
|
append text after cursor
|
| r |
|
replace character at cursor
|
| R |
|
Replace multiple characters
|
| J |
|
Join lines - default is two lines |
| dd |
|
Delete the current line (The deleted line is copied to the buffer)
|
| ndd |
|
Delete n lines starting at the current line (n = number of lines to delete) - (The deleted lines are copied to the buffer) |
| yy |
|
Yank the current line (The current line is copied to the buffer) |
| nyy |
|
Yank n lines starting at the current line (n = number of lines to Yank) - (The Yank'd lines are copied to the buffer)
|
| P |
|
Paste the contents of the buffer to the line after the cursor
|
| D |
|
Delete from the cursor to the end of the current line
|
| nG |
|
Go to line n (n = number of line) - If no number is given defaults to last line
|
| H |
|
Go to first line of file
|
| /string |
|
finds the next occurance of the text string
|
| n |
|
Finds the next occurance of the last search string
|
| ?string |
|
Find the last occurance of the text string
|
| ^F |
|
Go forward a pase
|
| ^B |
|
Go Back a page
|
| ^L |
|
Refresh (Redraw) the page
|
| u |
|
Undo the last change
|
| U |
|
Undo all changes on a line while still on that line
|
| :wq |
|
Save (write) the file and exit (quit) VI
|
:w name
|
|
Save (write) the file as name
|
:n1,n2 w name
|
|
Save (write) lines n1 through n2 as file name
|
| :q! |
|
Exit (quit) VI without saving changes
|
| ZZ |
|
write the contents of the buffer to the current file and Exit (quit) VI
|
| :f |
|
Display file information at the bottom of the screen
|
|