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
|
:viusage = summary of all keyboard shortcuts
:options = shows currently :set options (with descriptions)
leader key = usually set to backslash expects a quick command
[normal mode]
f{char} = move cursor to the character {char}
gf = open file under cursor
<C-w>gf = open file under cursor in a tab
<C-w>] = jump to the tag under the cursor in a new window
<C-t> = jump back from where that ^ brought you
K = keyword lookup for the word under the cursor (see :help kp)
w = next word
e = end of word (=inner word)
@see: :h text-objects
ci' = change between single quote
ci" = change between double quote
ci( = change between brace
cit = change XML Tag
ciw = select inner word
caw = select 'a word'
" where c can be replaced by v for visual mode
:%s/foo/bar/g = replace all foo with bar
:g/foo/s/bar//g = on lines with foo replace bar with nothing
:g!/foo/s/bar//g = on lines not containing foo replace bar with nothing
[visual mode] # with selected lines
gq = formats text so that it fits in whatever :set textwidth was set
iB = select block between curly braces (:help object-select)
[commands]
:spell [word] = adds a word to the current dictionary (no mistake any more)
:set list = display non printable characters
:retab = replaces tabs with spaces
:set expandtab = in insert mode: replace tab with spaces
:Explore = cli version open file dialog (file explorer)
:Lex = use netrw as project drawer (stays open in its own window)
:only = 'maximize' current buffer
[navigation]
<CTRL-]> = look up the tag under the cursor (help links as well)
<CTRL-T> = return back from tag under the cursor
gd = jump to the declaration of the variable under the cursor
[macros] # record and play back a series of vim commands
qa = start (q) macro recording in register a (can be anything)
q = stop macro recording
@a = replay macro a
:'<,'>normal @a = apply a to every line in the current selection
:reg = lists all registers (including those with macros in them)
[registers]
notice, that registers get used for both: macro recordings and copying text
:reg = shows contents of all registers
"0p = pasts from register 0, which is the same as "", but not overwritten by dd
"ap = same for register a
"0yy = yanks to register 0 (same as y by itself)
"ay = yanks current selection to register a (in visual mode)
[marker]
ma = set marker a-z (a in this case)
`a = go to marker a (line & column)
'a = go to marker a (line, first non blank), same as `a^
[hotkeys]
<C-A>, <C-X> = increment, decrement number under the cursor
[windows]
<C-W>v = splits buffer vertically (screen uses |)
<C-W>s = splits buffer horizontally (same as screen)
<C-W>w = moves the cursor to the next window and back
<C-W>[dir] = moves the cursor in that direction (use hjkl or arrow keys)
<C-W>[HK] = make a vertical split horizontal and vice versa
[vimdiff]
do = get changes from other window into the current
dp = put changes from current window into the other
]c = jump to the next change
[c = jump to the prevous change
[folds]
za = toggle a fold
zM = close all folds
zR = opens all folds (unfold all)
zE = eliminates all folds
[buffers]
:bn = buffer next
:bp = buffer previous
:bd = buffer dispatch (close)
:b <tab> = switch buffer by name (use <tab> and <return>)
:set nobuflisted = hide buffer in buffer list (great for neovim's terminal)
[special]
g CTRL-g = display file properties including word and char count
q: = show command history and use it like a normal buffer
z= = show spellcheck suggestions
[completions]
CTRL-O = display completions: omnicomplete (context dependant completions)
CTRL-X CTRL-F = display completions: file name (using vim-internals omnicomplete)
CTRL-N CTRL-P = display completions: file keywords
CTRL-K = display completions: dictionary
CTRL-T = display completions: thesaurus
CTRL-I = display completions: include files
CTRL-] = display completions: tags
CTRL-D = display completions: (marcro-) definitions
CTRL-V = display completions: vim command line
CTRL-U = display completions: user-defined
[annoyances]
gv = visual mode: reselect last selection
CTRL-o = lets the caret jump back to the previous location
CTRL-L = redraws the complete screen
CTRL-R<register> = in insert mode and command line: paste contents of <register> (e.g. : for last command, * for clipboard)
CTRL-R = in normal mode: redoes what has been undone with u
"<register>p = in normal mode: paste paste contents of <register>
[netrw]
:Lex = open the netrw-view as project drawer
gn = makes the directory under the cursor the root directory
a = toggles display of hidden files
[filetype:css]
viB:sort = sort inner block by name
[vim commands]
:for i in range(1,12) | put ='2016-'.i | endfor
[fancy utf-8 symbols]
௵
[debugging]
:profile! start /tmp/profile.log
:profile func *
:profile file *
" At this point do slow actions
:profdel *
:e /tmp/profile.log
[vim modeline]
filetype can have multiple values, like python.django
The last line can be a mode line, which holds settings like tab width:
# vim: noai:ts=2:sw=2 filetype=dosini.text
|