Skip to content

Commit 9f15226

Browse files
committed
add vim cheatsheet
1 parent 6e3f471 commit 9f15226

File tree

2 files changed

+160
-0
lines changed

2 files changed

+160
-0
lines changed

cheatsheets/git.ini

+1
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ Undo all commits after = git reset 'commit'
3636
Add a remote upstream repo = git remote add upstream <URL>
3737
Sync with remote upstream repo = git pull upstream master
3838
Append new commit to keep single commits = git commit -a --amend
39+
List branches of remote repo = git branch -r

cheatsheets/vim.ini

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
[main]
2+
name=vim
3+
desc=vim cheat sheet from https://vim.rtorr.com
4+
[global]
5+
open help for keyword = :help keyword
6+
open file = :o file
7+
save file as = :saveas file
8+
close current pane = :close
9+
open man page for word under the cursor = K
10+
11+
[cursor]
12+
move cursor left = h
13+
move cursor right = l
14+
move cursor up = k
15+
move cursor down = j
16+
move to top of screen = H
17+
move to middle of screen = M
18+
move to bottom of screen = L
19+
jump forwards to the start of a word = w
20+
jump forwards to the start of a word (words can contain punctuation) = W
21+
jump forwards to the end of a word = e
22+
jump forwards to the end of a word (words can contain punctuation) = E
23+
jump backwards to the start of a word = b
24+
jump backwards to the start of a word (words can contain punctuation) = B
25+
move to matching character (default supported pairs: '()', '{}', '[]' - use :h matchpairs in vim for more info) = %%
26+
jump to the start of the line = 0
27+
jump to the first non-blank character of the line = ^
28+
jump to the end of the line = $
29+
jump to the last non-blank character of the line = g_
30+
go to the first line of the document = gg
31+
go to the last line of the document = G
32+
go to line 5 = 5G
33+
jump to next occurrence of character x = fx
34+
jump to before next occurrence of character x = tx
35+
jump to previous occurence of character x = Fx
36+
jump to after previous occurence of character x = Tx
37+
repeat previous f, t, F or T movement = ;
38+
repeat previous f, t, F or T movement, backwards = ,
39+
jump to next paragraph (or function/block, when editing code) = }
40+
jump to previous paragraph (or function/block, when editing code) = {
41+
center cursor on screen = zz
42+
move back one full screen = Ctrl + b
43+
move forward one full screen = Ctrl + f
44+
move forward 1/2 a screen = Ctrl + d
45+
move back 1/2 a screen = Ctrl + u
46+
47+
[cut & paste]
48+
yank (copy) a line = yy
49+
yank (copy) 2 lines = 2yy
50+
yank (copy) the characters of the word from the cursor position to the start of the next word = yw
51+
yank (copy) to end of line = ys
52+
put (paste) the clipboard after cursor = p
53+
put (paste) before cursor = P
54+
delete (cut) a line = dd
55+
delete (cut) 2 lines = 2dd
56+
delete (cut) the characters of the word from the cursor position to the start of the next word = dw
57+
delete (cut) to the end of the line = D or d$
58+
delete (cut) character = x
59+
60+
[Search and replace]
61+
search for pattern = /pattern
62+
search backward for pattern = ?pattern
63+
'very magic' pattern: non-alphanumeric characters are interpreted as special regex symbols (no escaping needed) = \vpattern
64+
repeat search in same direction = n
65+
repeat search in opposite direction = N
66+
replace all old with new throughout file = :%%s/old/new/g
67+
replace all old with new throughout file with confirmations = :%%s/old/new/gc
68+
remove highlighting of search matches = :noh
69+
70+
[insert]
71+
insert before the cursor = i
72+
insert at the beginning of the line = I
73+
insert (append) after the cursor = a
74+
insert (append) at the end of the line = A
75+
append (open) a new line below the current line = o
76+
append (open) a new line above the current line = O
77+
insert (append) at the end of the word = ea
78+
79+
[multiple]
80+
edit a file in a new buffer = e
81+
go to the next buffer = :bnext or :bn
82+
go to the previous buffer = :bprev or :bp
83+
delete a buffer (close a file) = :bd
84+
list all open buffers = :ls
85+
open a file in a new buffer and split window = :sp file
86+
open a file in a new buffer and vertically split window = :vsp file
87+
split window = Ctrl + ws
88+
switch windows = Ctrl + ww
89+
quit window = Ctrl + wq
90+
split window vertical = Ctrl + wv
91+
move cursor to the left window (vertical split) = Ctrl + wh
92+
move cursor to the right window (vertical split) = Ctrl + wl
93+
move cursor to the below window (horizontal split) = Ctrl + wj
94+
move cursor to the above window (horizontal split) = Ctrl + wk
95+
96+
[edit]
97+
replace a single character = r
98+
join line below to the current one with one space in between = J
99+
join line below to the current one without space in between = gJ
100+
change (replace) entire line = cc
101+
change (replace) to the end of the word = cw
102+
change (replace) to the end of the line = c$
103+
delete character and substitute text = s
104+
delete line and substitute text (same as cc) = S
105+
transpose two letters (delete and paste) = xp
106+
undo = u
107+
redo = Ctrl + r
108+
repeat last command = .
109+
110+
[visual mode - mark text]
111+
start visual mode, mark lines, then do a command (like y-yank) = v
112+
start linewise visual mode = V
113+
move to other end of marked area = o
114+
start visual block mode = Ctrl + v
115+
move to other corner of block = O
116+
mark a word = aw
117+
a block with () = ab
118+
a block with {} = aB
119+
inner block with () = ib
120+
inner block with {} = iB
121+
122+
[visual command]
123+
shift text right = >
124+
shift text left = <
125+
yank (copy) marked text = y
126+
delete marked text = d
127+
switch case = ~
128+
129+
[Search in multiple files]
130+
search for pattern in multiple file = :vimgrep /pattern/ {file} e.g. :vimgrep /foo/ **/*
131+
jump to the next match = :cn
132+
jump to the previous match = :cp
133+
open a window containing the list of matches = :copen
134+
135+
[register]
136+
show registers content = :reg
137+
yank into register x = "xy
138+
paste contents of register x = "xp
139+
140+
[marks]
141+
list of mark = :marks
142+
set current position for mark A = ma
143+
jump to position of mark A = `a
144+
yank text to position of mark A = y`a
145+
146+
[macros]
147+
record macro a = qa
148+
stop recording macro = q
149+
run macro a = @a
150+
rerun last run macro = @@
151+
152+
[Exiting]
153+
write (save) the file, but don't exit = :w
154+
write out the current file using sudo = :w !sudo tee %%
155+
write (save) and quit = :wq or :x or ZZ
156+
quit (fails if there are unsaved changes) = :q
157+
quit and throw away unsaved changes = :q! or ZQ
158+
write (save) and quit on all tabs = :wqa
159+

0 commit comments

Comments
 (0)