Changing modes
<ESC> |
Exit from other modes into NORMAL mode |
i/I |
Enter INSERT mode, cursor placed before the current character/first character in line |
a/A |
Enter INSERT mode, cursor placed after the current character/the end of the line |
o/O |
Creates a new, empty line below/above the cursor, and enter INSERT mode |
v |
Enter Visual mode, cursor movement selection |
V |
Enter Visual mode, line selection |
<CTRL>-v |
Enter Visual mode, block selection |
: |
Enter COMMAND-LINE mode |
NORMAL mode
J |
Join line at cursor with line below it |
u |
Undo last edit |
U |
Undoes all the changes made on the last line that was edited |
p |
Put |
<CTRL>-r |
Reverse the preceding command |
ZZ |
Writes the file and exits |
Operators
y |
Copy (Yank) |
c |
Change (deletes and enters INSERT mode) |
d |
Delete |
Selection
w |
Word |
W |
WORD |
s |
Sentence |
p |
Paragraph |
[ or ] |
[] block |
( or ) or b |
() block |
< or > |
<> block |
{ or } |
{} Block |
These are preceded by either i (Inner) or a (as in A word), and the inner ones exclude space and delimiters from the selection
Motions
w/W |
Start of the next word/WORD |
b/B |
Start of the previous word/WORD |
e/E |
End of the next word/WORD |
ge/gE |
End of the previous word/WORD |
0 or <HOME> |
Very first character of the line |
^ |
First non-blank character of the line |
$ |
End of a line (eol) |
f/F{char} |
Forward/backwards to character {char} |
t/T{char} |
Like f/F but stops on character before (To) |
% |
Matching pair (for parenthesis, square brackets and squiglies) |
Cursor motions
h or <RIGHT> |
Right |
k or <UP> |
Up |
j or <DOWN> |
Down |
l or <LEFT> |
Left |
H |
First line on screen (High) |
M |
Middle line on screen (Middle) |
L |
Last line on screen (Low) |
Scrolling Motions
<CTRL>-u |
Scroll half a page up |
<CTRL>-d |
Scroll half a page down |
<CTRL>-y |
Scroll up one line |
<CTRL>-e |
Scroll down one line |
<CTRL>-b |
Scroll up (Back) one screen minus 2 lines |
<CTRL>-f |
Scroll down (Forward) one screen minus 2 lines |
zt |
Move cursor line to the top of screen |
zz |
Move cursor line to middle of screen |
zb |
Move cursor line to the bottom of screen |
Windows
<CTRL>-w w |
Jump between the windows |
<CTRL>-w t |
Move to the TOP window |
<CTRL>-w b |
Move to the BOTTOM window |
<CTRL>-w + |
Increase the size of a window |
<CTRL>-w - |
Decrease the size of a window |
You can also use <CTRL>-w followed by h, j, k and l to navigate opened windows, and H, J, K and L to move windows around.
|
|
Shortcuts
s |
Change one character |
x |
Delete character under the cursor |
X |
Delete character left of the cursor |
r |
Waits for you to type a character, and will replace the character under the cursor with it |
C |
Change to the end of line |
D |
Delete to the end of line |
yy |
Copy a whole line |
cc or S |
Change a whole line |
dd |
Deletes a whole line |
. |
Repeats the last change (except undo) |
VISUAL BLOCK mode
o |
Change cursor to the other end of the selection |
O |
Change corner in block selection |
I{string}<Esc> |
Inserts the text {string} in each line, to the left of the block |
A{string}<Esc> |
Inserts the text {string} in each line, to the right of the block |
$A{string}<Esc> |
Same as A{string}<Esc>, but will append the string in the lines that are shorter |
C{string}<Esc> |
Deletes the block and then throws you into Insert mode to enable you to type in a string |
Search
/{pattern} |
Search forwards |
?{pattern} |
Search backwards |
n/N |
Move to next/previous occurrence |
<UP> and <DOWN> |
Move through the history of search commands |
* |
Grab the word under the cursor and search forward |
# |
grab the word under the cursor and search backwards |
Patterns
\ |
Escape special characters below to look for them |
^ |
Matches the beginning of a line |
$ |
Matches the end of a line |
. |
Matches any existing character |
Substitution ranges
No range specified |
Current line |
% |
All lines |
{number} |
Line |
. |
First line |
$ |
Last line |
- 0r + {number} |
Line offset from range boundary |
You can use a comma to specify an interval, .,$ means from the first line to the last line. You can also use patterns.
Substitution flags
No flag specified |
First occurrence in range |
g |
All ocurrences in range |
c |
Ask for confirmation before it performs each substitution |
COMMAND-LINE mode
edit <filename> |
Edit new file, or load existing |
q |
Quit |
q! |
Quit and throw changes away |
saveas <filename> |
Save contents as <filename> and continue editing |
file <filename> |
Change current file name (does not write it) |
substitute or s |
Find and replace, in the form [range]substitute/from/to/[flags] (see substitution pannels) |
Window commands
new |
Open a window on a new, empty file above the current one |
split |
Open a new window above the current one. If file name is provided, opens a second window and starts editing the given file |
close |
Close current window |
only |
Closes all windows, except for the current one |
Prepend v in new and split for a vertical split with a new window to the left
|
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by marconlsantos