vi keyboard shortcuts | ||
| Cursor control and position | ||
| Editing | ||
| File Handling | ||
| . | Cursor control and position | |
| Left | h | |
| Down | j | |
| Up | k | |
| Right | l (or spacebar) | |
| Forward one word | w | |
| Back one word | b | |
| End of word | e | |
| Beginning of current sentence | ( | |
| Beginning of next sentence | ) | |
| Beginning of current paragraph | { | |
| Beginning of next paragraph | } | |
| Beginning of current section | [[ | |
| Beginning of next section | ]] | |
| Start of current line | 0 | |
| End of current line | $ | |
| First non-white character of current line | ^ | |
| First character of next line | + or RETURN | |
| First character of previous line | - | |
| character n of current line | n | | |
| Top line of current screen | H | |
| Middle line of current screen | M | |
| Last line of current screen | L | |
| n lines after top line of current screen | nH | |
| n lines before last line of current screen | nL | |
| Forward one screen | Ctrl-F | |
| Back one screen | Ctrl-B | |
| Down half a screen | Ctrl-D | |
| Up half a screen | Ctrl-U | |
| Display another line at bottom of screen | Ctrl-E | |
| Display another line at top of screen | Ctrl-Y | |
| Redraw screen with cursor at top | z RETURN | |
| Redraw screen with cursor in middle | z . | |
| Redraw screen with cursor at bottom | z - | |
| Redraw screen without re-positioning | Ctrl-L | |
| Redraw screen without re-positioning | Ctrl-R | |
| Search for text (forwards) | /text | |
| Repeat forward search | / | |
| Search for text (backwards) | ?text | |
| Repeat previous search backwards | ? | |
| Repeat previous search | n | |
| Repeat previous search, but it opposite direction | N | |
| Go to line n after text | /text/+n | |
| Go to line n before text | ?text?-n | |
| Find match of current parenthesis, brace, or bracket. | % | |
| Display line number of cursor | Ctrl-G | |
| Move cursor to line number n | nG | |
| Move cursor to line number n | :n | |
| Move to last line in file | G | |
Editing | ||
| Append to end of current line | A | |
| Insert before cursor | i | |
| Insert at beginning of line | I | |
| Open line above cursor | o | |
| Open line below cursor | O | |
| End of insert mode | ESC | |
| Insert a tab | Ctrl-I | |
| Move to next tab position | Ctrl-T | |
| Move back one character | Backspace | |
| Delete current line | Ctrl-U | |
| Quote next character | Ctrl-V | |
| Move back one word | Ctrl-W | |
| Change word | cw | |
| Change line | cc | |
| Change from current position to end of line | C | |
| Delete current line | dd | |
| Delete n lines | ndd | |
| Delete remainer of line | D | |
| Delete word | dw | |
| Delete rest of paragraph | d} | |
| Delete back to start of line | d^ | |
| Delete up to first occurance of pattern | c/pat | |
| Delete up to next occurance of pattern | dn | |
| Delete up to and including a on current line | dfa | |
| Delete up to, but not including, a on current line | dta | |
| Delete up to last line on screen | dL | |
| Delete to end of file | dG | |
| Join two lines | J | |
| Insert buffer after cursor | p | |
| Insert buffer before cursor | P | |
| Replace character with x | rx | |
| Replace text beginning at cursor | Rtext | |
| Substitute character | s | |
| Substitute n characters | ns | |
| Substitute entire line | S | |
| Undo last change | u | |
| Restore current line | U | |
| Delete current cursor position | x | |
| Delete back one character | X | |
| Delete previous n characters | nX | |
| Repeat last change | . | |
| Reverse case | ~ | |
| Copy current line to new buffer | y | |
| Copy current line | yy | |
| Copy current line into buffer x | "xyy | |
| Delete and append into buffer x | "Xd | |
| Put contents of buffer x | "xp | |
| Copy up to next section heading | y]] | |
| Copy to end of word | ye | |
File Handling | ||
| :w | Write file | |
| :w! | Write file (ignoring warnings) | |
| :w! file | Overwrite file (ignoring warnings) | |
| :wq | Write file and quit | |
| :q | Quit | |
| :q! | Quit (even if changes not saved) | |
| :w file | Write file as file, leaving original untouched | |
| ZZ | Quit, only writing file if changed | |
| :x | Quit, only writing file if changed | |
| :n1,n2w file | Write lines n1 to n2 to file | |
| :n1,n2w >> file | Append lines n1 to n2 to file | |
| :e file2 | Edit file2 (current file becomes alternate file) | |
| :e! | Reload file from disk (revert to previous saved version) | |
| :e# | Edit alternate file | |
| % | Display current filename | |
| # | Display alternate filename | |
| :n | Edit next file | |
| :n! | Edit next file (ignoring warnings) | |
| :n files | Specify new list of files | |
| :r file | Insert file after cursor | |
| :r !command | Run command, and insert output after current line | |
Sunday, March 29, 2009
vi keyboard shortcuts
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment