Created
November 30, 2014 21:34
-
-
Save superacidjax/0b5e279ff83d4fcb36cb to your computer and use it in GitHub Desktop.
Basic Vim Cheat Sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VIM Cheatsheet | |
Text Entry | |
a Append text following current cursor position | |
A Append text to the end of current line | |
i Insert text before the current cursor position | |
I Insert text at the beginning of the cursor line | |
o Open up a new line following the current line and add text there | |
O Open up a new line in front of the current line and add text there | |
Cursor Movement Commands | |
h Moves the cursor one character to the left | |
l Moves the cursor one character to the right | |
k Moves the cursor up one line | |
j Moves the cursor down one line | |
:n Cursor goes to the specified (n) line | |
^F (CTRL F) Forward screen | |
^B Backward screen | |
^f One page forward | |
^b One page backward | |
^U Up half screen | |
^D Down half screenful | |
$ Move cursor to the end of current line | |
0 (zero) Move cursor to the beginning of current line | |
w Forward one word | |
b Backward one word | |
Exit Commands | |
:wq Write file to disk and quit the editor | |
:q! Quit (no warning) | |
:q Quit (a warning is printed if a modified file has not been saved) | |
Text Deletion Commands | |
x Delete character | |
dw Delete word from cursor on | |
db Delete word backward | |
dd Delete line | |
d$ Delete to end of line | |
d^ (d caret, not CTRL d) Delete to beginning of line | |
Yank (has most of the options of delete)-- VI's copy command | |
yy yank current line | |
y$ yank to end of current line from cursor | |
yw yank from cursor to end of current word | |
5yy yank, for example, 5 lines | |
Paste (used after delete or yank to recover lines.) | |
p paste below cursor | |
P paste above cursor | |
"2p paste from buffer 2 (there are 9) | |
u Undo last change | |
U Restore line | |
J Join next line down to the end of the current line | |
File Manipulation Commands | |
:w Write workspace to original file | |
:w file Write workspace to named file | |
:e file Start editing a new file | |
:r file Read contents of a file to the workspace | |
Other Useful Commands | |
Most commands can be repeated n times by typing a number, n, before the command. For example 10dd means delete 10 lines. | |
. Repeat last command | |
cw Change current word to a new word | |
r Replace one character at the cursor position | |
R Begin overstrike or replace mode – use ESC key to exit | |
Search & Replace | |
:/ pattern Search forward for the pattern | |
:? pattern Search backward for the pattern | |
n (used after either of the 2 search commands above to | |
continue to find next occurrence of the pattern. | |
:g/pat1/s//pat2/g replace every occurrence of pattern1 (pat1) with pat2 | |
:g/a/s// /g replace the letter a, by blank | |
:g/a/s///g replace a by nothing | |
note: Even this command be undone by u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment