Next: Using vi
Up: Creating And Editing Files
Previous: vi modes
- Cursor Movement Commands
-
hjkl
Moves cursor in direction of arrow in command mode. - <linenum>G<CR>
Goes to beginning of <linenum> line in document.
If <linenum> isn't included, goes to end of document. - w b e
Skip forward one word, back one word, or to the end of the word in a
sentence. - 0 (zero)
Sends cursor to the beginning of a line. - $
Sends cursor to the end of a line.
- Screen Management
- H,M
Move cursor to the Home position (Top of screen).
Move cursor to the Middle position (Halfway down screen) - <ctrl-f>,<ctrl-b>
Move Forwards or Backwards one screenful. - <ctrl-y>,<ctrl-e>
Scroll screen up or down one line. - <ctrl-l>
Redraw screen. Useful for cleaning up screen
if mode information on the lower right of the screen starts to
be written in strange places or if a message from another process
or from the system is written to your screen.
- Text Change Commands
- r <char>
Replace character under cursor with <char>. - R
Replace (typeover) all existing characters.
Press <ESC> to stop typeover. - <<,>>
Shift entire line of text to the left or right. - J
Append the following line to the current line. -
Change the case of the character under the cursor
and move right one position.
- Marking Text
- m <lowercasechar>
Mark location with a mark named after the lower case character. - '<lowercasechar>
Goto line marked with <lowercasechar>.
- Text Searches
- /<targetstring><CR>
Forward search for target string. - ? <targetstring><CR>
Backward search for target string. - n N <targetstring><CR>
Repeat last search for Next occurrence of target string.
`n` is a forward search, 'N' is a backward search. - '' (Two single quotes) Returns cursor to spot where search
began.
- Text Deletion
- [count]x
Deletes count characters from cursor position. Default is 1 character. - [count]dw
Delete count words from cursor position. Default is 1 word. - [count]dd
Delete count lines from cursor position. Default is 1 line. - D
Delete from cursor position to end of line. - u
Undo last editing change.
- Text Buffers
- <numberoflines> Y
Yanks lines of text into a buffer. - p P
Puts text after (p) or before (P) current line.
- File Manipulation
Note: to use a colon (:) command, get into command mode then press ':'.- :r filename <CR>
Reads in a copy of the file specified on the line after the current line.
(if no filename is given, the file you are editing is read in from disk) - :w<CR>
Write edit buffer to original file (This assumes that you started
vi by typing vi <filename>). - :w filename <CR>
Write edit buffer to named file. - :wq <CR> or ZZ <CR>
Write edit buffer to original file, then exit vi. - :e newfilename <CR>
Start editing a new file. - :q <CR>
Quit with a warning if edit buffer not saved. - :q! <CR>
Quit with no warning. If edit buffer has not been saved to a file,
it will be lost.
Next: Using vi
Up: Creating And Editing Files
Previous: vi modes
Larry Latour
Fri Sep 12 08:12:59 EDT 1997