-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathcheatsheet-default.txt
390 lines (376 loc) · 16 KB
/
cheatsheet-default.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# Modified from https://github.com/lifepillar/vim-cheat40/blob/master/cheat40.txt
## file-vim
New untitled document | :enew
New/open file or dir | :e {file}
Split open (horizontal) | :sp [file]
Split open (vertical) | :vs [file]
Reopen last opened file | <C-o><C-o>
Open with external app | gx
Close file | :bd
Close all | :%bd
Save | :w
Save (only if modified) | :up
Save as | :sav {filename}
Save all | :wa
Save read-only file | :w!
Save session | :mks
Restore session | :so Session.vim
Reload file from disk | :e
Revert to last saved | :e!
Convert buffer to HTML | :TOhtml
Print document | :hardcopy
Quit (window) | :q
Save and quit (window) | :x
Save and quit (window) | ZZ
Quit without saving | :q!
Quit without saving | ZQ
Save all and exit Vim | :xa
Exit Vim without saving | :qa!
## edit-vim
Back to normal mode | <Esc>
Cancel command/operation | <C-c>
Insert at cursor pos. | i
Append after cursor | a
Insert at start of line | I
Append at end of line | A
Open new line below | o
Open new line above | O
Replace character with {c} | r{c}
Replace mode/overwrite | R
Change | c
Replace line | cc
Repeat last command | .
Undo | u
Redo | <C-r>
Next text state | g+
Prev text state | g-
Cut | d
Cut into register {r} | "{r}d
Cut into OS clipboard | "*d
Cut {n} lines | {n}dd
Cut until EOL | D
Cut {n} characters forward
Cut {n} characters backwards | {n}X
Cut all | :%d
Copy | y
Copy into register {r} | "{r}y
Copy into OS clipboard | "*y
Copy {n} lines | {n}yy
Copy until EOL | y$
Copy all | :%y
Paste after cursor | p
Paste before cursor | P
Paste from register {r} | "{r}p
Paste from register {r} | <C-r>{r}
Paste from OS clipboard | "*p
Paste after and align | ]p
Paste before and align | ]P
Visual mode (select) | v
Linewise visual mode | V
Block visual mode | <C-v>
Insert in selected lines | <C-v>{Move}I
Append to selected lines | <C-v>{Move}A
Change in selected lines | <C-v>{Move}c
Delete in selected lines | <C-v>{Move}x
Reselect visual | gv
Select all | ggVG
Delete previous word | <C-w>
Erase line before cursor | <C-u>
Record macro into register {r} | q{r}
Stop recording macro | q
Run recorded macro in register {r} | @{r}
Repeat last macro | @@
Repeat last Ex command | @:
Run {Cmd} in all buffers | :bufdo {Cmd}
## text-objects-vim
Around word | aw
Inside word | iw
Around WORD | aW
Inside WORD | iW
Around sentence | as
Inside sentence | is
Around paragraph | ap
Inside paragraph | ip
Around parentheses | a( , ab
Inside parentheses | i( , ib
Around brackets | a[
Inside brackets | i[
Around braces | a{ , zB
Inside braces | i{ , iB
Around (XML) tags | at
Inside (XML) tags | it
Around < and > | a<
Inside < and > | i<
Around double quotes | a"
Inside double quotes | i"
Around simple quotes | a'
Inside simple quotes | i'
Around backticks | a`
Inside backticks | i`
## text-manipulation-vim
Change to uppercase | gU
Change to lowercase | gu
Uppercase line | gUU
Lowercase line | guu
Change to uppercase | U
Change to lowercase | u
Toggle case | ~
Toggle case | ~
Indent (. to repeat) | >
Unindent (. to repeat) | <
Reindent | =
Indent line (. repeats) | >>
Unindent (. repeats) | <<
Reindent line | ==
Indent line (insert mode) | <C-t>
Unindent line (insert mode) | <C-d>
Hard-wrap (cursor moves) | gq
Hard-wrap (cursor stays) | gw
Format current line | gww
Join with next line | J
Join next line preserve spaces | gJ
Use hard tabs | :set noet
Use soft tabs (spaces) | :set et
Detab (needs 'et' on) | :retab
Entab (needs 'et' off) | :retab!
Set text width to {n} | :set tw={n}
Sort selected lines | :sort
Sort+remove duplicates | :sort u
Run macro in reg {r} for each line | :norm @{r}
Run {Cmd} on lines matching {P} | :g/{P}/{Cmd}
Autocomplete (search forward) | <C-n>
Autocomplete (search backwards) | <C-p>
Omnicomplete | <C-x><C-o>
Line autocomplete | <C-x><C-l>
Insert digraph | <C-k>{c}{c}
Insert calculated expr. | <C-r>=
Increment number by {n} | {n}<C-a>
Decrement number by {n} | {n}<C-x>
## spell-vim
Toggle spell checking | :setl spell!
To next misspelled word | ]s
To prev misspelled word | [s
Suggest corrections (normal mode) | z=
Suggest corrections (insert mode) | <C-x>s
Permanently mark as correct | zg
Undo mark as correct | zug
Temporarily mark as correct | zG
Permanently mark as incorrect | zw
Undo mark as incorrect | zuw
Temporarily mark as incorrect | zW
## navigation-vim
Scroll down a page | <C-f>
Scroll up a page | <C-b>
Scroll down half a page | <C-d>
Scroll up half a page | <C-u>
Scroll down a bit | <C-e>
Scroll up a bit | <C-y>
Scroll horizontally right | {n}zl
Scroll horizontally left | {n}zh
Scroll horizontally half a screen | zL
Scroll horizontally half a screen | zH
Scroll line to top | zt
Scroll to bottom | zb
Scroll to center | zz
Toggle soft-wrapping | :setl wrap!
Page guide at column {n} | :setl cc={n}
No page guide | :setl cc=
Toggle line numbers | :setl nu!
Toggle relative line numbers | :setl rnu!
Toggle invisibles | :setl list!
Unfold all | zR
Show files | :ls
Edit buffer (autocomplete) | :b <Tab>
Edit buffer {n} | :b{n}
Edit last edited file | <C-^>
Edit next buffer | :bn
Edit prev buffer | :bp
Edir prev in arg list | :prev
Edir next in arg list | :next
Get file info | <C-g>
Character info | ga
Go to file under cursor | gf
Line/word/char count | g<C-g>
Toggle cursorline | :setl cul!
Toggle search highlight | :setl hls!
Cycle match groups (eg. if,else,end) | g%
## search-vim
Toggle ignore case | :set ic!
Search forward for {P} | /{P}
Search backward for {P} | ?{P}
Go to next match | n
Go to previous match | N
Select up to next match | gn
Select up to prev match | gN
Search word under cursor backward | *
Search word under cursor forward | #
Go to next match during search | <C-G>
Go to previous match during search | <C-T>
Find and replace | :s/{P}/{P}/g
Find and replace confirm | :s/{P}/{P}/gc
Find and replace all | :%s/{P}/{P}/g
Open quickfix | :copen
Prev in quickfix list | :cp
Next in quickfix list | :cn
Close quickfix | :cclose
Open location list | :lopen
Prev in location list | :lp
Next in location list | :lne
Close location list | :lclose
Next command (command mode) | <C-n>
Prev command (command mode) | <C-p>
Browse command history | q:
Browse search patterns | q/
Use this file for diff | :diffthis
Exit diff mode | :diffoff!
Re-scan files for diffs | :diffupdate
Next difference | ]c
Prev difference | [c
Diff put | dp
Diff obtain | do
Get differences | :diffget
Put differences | :diffput
## movement-vim
Left | h
Right | l
Up | k
Down | j
Up (honor soft-wrapping) | gk
Down (honor soft-wrapping) | gj
Start of next word | w
Start of prev word | b
End of next word | e
End of prev word | ge
Start of next WORD | W
Start of prev WORD | B
End of next WORD | E
End of prev WORD | gE
Start of line | 0
End of line | $
This line 1st non-blank | ^
Next line 1st non-blank | +
Prev line 1st non-blank | -
First line | gg
Last line | G
Next {c} in this line | f{c}
Just before next {c} | t{c}
Prev {c} in this line | F{c}
Just after prev {c} | T{c}
Repeat f/t/F/T forward | ;
Repeat f/t/F/T backward | ,
Prev pos in change list | g;
Next pos in change list | g,
Go to line {n} | :{n}
Go to column {n} | {n}|
Jump to line {n} | {n}G
Jump to next blank line | }
Jump to prev blank line | {
Jump to begin of block | [{
Jump to end of block | ]}
Jump to end of sentence | )
Jump to beg. of sentence | (
Jump to end of section | ]]
Jump to beg. of section | [[
Jump to top of window | H
Jump to middle | M
Jump to bottom | L
Jump to matching delim | %
Jump to specified tag | :tag [tagname]
Jump to older tag | <C-t>
Jump to tag definition | <C-]>
Jump to tag definition, show choices | g]
Jump or show choices | g<C-]>
To next matching tag | :tn
To prev matching tag | :tp
Set mark {c} | m{c}
Jump to mark at {c} | `{c}
View all marks | :marks
Remove marks | :delmarks {mark}
Jump to definition | gd
To prev jump position | <C-o>
To next jump position | <C-i>
Go to last insertion and INSERT | gi
## folds-vim
Go to start of next fold | zj
Go to end of previous fold | zk
Open fold under cursor | zo
Open all folds under cursor | zO
Close fold under cursor | zc
Close all folds under cursor | zC
Toggle fold under cursor | za
Toggle all folds under cursor | zA
Open folds to show cursor line | zv
Close all folds | zM
Open all folds | zR
Fold more | zm
Fold less | zr
Update folds | zx
## window-vim
New horizontal split | :new
New horizontal split | <C-w><C-n>
New vertical split | :vnew
Close window | <C-w>c
Close inactive windows | <C-w><C-o>
Split horizontally | <C-w>s
Split vertically | <C-w><C-v>
Exchange windows | <C-w><C-x>
Move to the very top | <C-w>K
Move to the very bottom | <C-w>J
Move to the far right | <C-w>L
Move to the far left | <C-w>H
One window per file | :ball
Cycle through windows | <C-w><C-w>
Back to previous window | <C-w><C-p>
Edit window to the left | <C-w><C-h>
Edit window below | <C-w><C-j>
Edit window above | <C-w><C-k>
Edit window to the right | <C-w><C-l>
Edit top window | <C-w><C-t>
Edit bottom window | <C-w><C-b>
All windows same size | <C-w>=
Maximize height | <C-w>_
Maximize width | <C-w>|
Decrease height | <C-w>-
Increase height | <C-w>+
Decrease width | <C-w><
Increase width | <C-w>>
Execute {Cmd} in all windows | :windo {Cmd}
## tabs-vim
New untitled tab | :tabnew
New/open in tab | :tabe [file]
Next tab | gt
Previous tab | gT
Go to tab {n} | {n}gt
Close tab | :tabc
Close all other tabs | :tabo
List tabs | :tabs
Move window to new tab | <C-w>T
Open one tab per buffer | :tab ball
Execute {Cmd} in all tabs | :tabdo {Cmd}
## filename-modifiers-vim
Full path | %:p
Relative to $HOME | %:~
Relative to current directory | %:.
Filename only (tail) | %:t
Remove last extension (get root) | %:r
Extension only | %:e
Escape special chars (use in shell) | %:S
Substitute first | %:s?pat?sub?
Substitute all | %:gs?pat?sub?
Get directory of file | %:p:h
## help-vim
Help | :h [helptag]
Help search | :helpgrep {searchterm}
Help on highlight test | :h hitest.vim
View mappings | :map [mapping]
View Insert mode mappings | :imap [mapping]
View registers | :reg
List of sourced files | :scr
List of digraphs | :digraphs
List all syntax items | :syn
## misc-vim
Show current directory | :pwd
Change directory | :cd {dir}
Change to home directory | :cd
Show value of {Var} | :echo {Var}
Show value of option | :set {Opt}?