Skip to content

Instantly share code, notes, and snippets.

@Pan-Maciek
Created December 10, 2019 12:06
Show Gist options
  • Save Pan-Maciek/0f8e1f68f2a6026edd6d537978a7a656 to your computer and use it in GitHub Desktop.
Save Pan-Maciek/0f8e1f68f2a6026edd6d537978a7a656 to your computer and use it in GitHub Desktop.
vim cheatsheat
Navigation
k
h l
j
H - move to top of screen
M - move to middle of screen
L - move to bottom of screen
K - open man page for word under the cursor
w - jump forwards to the start of a word
W - jump forwards to the start of a word (words can contain punctuation)
e - jump forwards to the end of a word
E - jump forwards to the end of a word (words can contain punctuation)
b - jump backwards to the end of a word
B - jump backwards to the end of a word (words can contain punctuation)
% - move to matching character (default supported pairs: () {} [] )
0 - jump to the start of the line
^ - jump to the first non-blank character of the line
$ - jump to the end of the line
g_ - jump to the last non-blank character of the line
gg - go to the first line of the document
G - go to the last line of the document
5G - go to line 5
fx - jump to next occurrence of character x
tx - jump to before next occurrence of character x
Fx - jump to previous occurrence of character x
Tx - jump to after previous occurrence of character x
; - repeat previous f, t, F, T movement
, - repeat previous f, t, F, T movement backwards
{ - jump to next paragraph
} - jump to previous paragraph
zz - center cursor on screen
Ctrl+e - move screen down one line (without moving cursor)
Ctrl+y - move screen up one line (without moving cursor)
Ctrl+b - move back one full screen
Ctrl+f - move forward one full screen
Ctrl+d - move forward 1/2 screen
Ctrl+u - move back 1/2 screen
i - insert before the cursor
I - insert at the beginning of the line
a - append after the cursor
A - append at the end of the line
o - append a new line below the current line
O - append a new line above the current line
r - replace a single character
J - join line below to the current one with one space in between
gJ - join line below to the current one without space in between
gwip - re-flow the paragraph
cc - change entire line
C - change to end of the line
s - delete character and substitute text
S - delete lines and substitute text (same as cc)
u - undo
Ctrl+r - redo
. - repeat last command
v - start visual mode
V - start line-wise visual mode
o - move to other end of marked area
Ctrl+v - start visual block mode
O - move to other corner of block
> - shift text right
< - shift text left
y - yank text
p - paste
d - delete
x - delete character under cursor
~ - switch case
gU - Uppercase
gu - lowercase
:reg - show registers content
"xy - yank into register x
"xp - paste contents of register x
:marks - list of marks
ma - set current position for mark A
`a - jump to position of mark A
qa - record macro a
q - stop recording macro
@a - run macro a
@@ - run last run macro
yy - copy line
Y - copy line
p - paste after cursor
P - paste before cursor
/pattern - search for pattern
?pattern - search for pattern backwards
n - repeat search in same direction
N - repeat search in opposite direction
:%s/old/new/g
:noh
:e file - edit a file in a new buffer
:bn - go to the next buffer
:bp - go to the previous buffer
:bd - delete a duffer (close a file)
:ls - list all open buffers
:sp file - open a file in a new buffer and split window
:vsp file - open a file in a new buffer and split window vertically
Ctrl+ws - split window
Ctrl+ww - switch windows
Ctrl+wq - quit a window
Ctrl+wv - split window vertically
Ctrl+wh - move cursor to the left
:tabnew - open a file in a new tab
Ctrl+wT - move current split window into its own tab
gt - :tabnext
gT - :tabprev
3gt - move to tab number 3
zo - open fold
zc - close fold
za - toggle fold
zv - open folds for this line
zM - close all
zR - open all
zm - fold more
zr - fold less
zx - update folds
Ctrl+A - increment number
Ctrl+X - decrement number
:tag Classname - jump to definition of classname
<C-]> - jump to definition
g] - see all definitions
<C-T> - go to last tag
<C-O> - go back a tag
<C-I> - go forward a tag
`^ - last position of cursor in the insert mode
`. - last change
`` - last jump
ma - mark this cursor position as a
`a - jump to cursor position a
' jump to the beginning of the line with position a
]p - paste under the cursor indentation level
]s - move to the next misspelled word
[s - move to previous misspelled word
z= - suggest spelling
zg - add word to spell list
zw - mark word as misspelled
zu - suggest words
* - search next instance
# - search prev instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment