1 ====== Vim Commands ======
6 | insert | when inserting or replacing text |
7 | normal | after pressing escape |
8 | command | after pressing : on normal mode |
9 | operator pending | after a command that needs an operator (e.g. :d) |
10 | visual | after pressing v, V or Ctrl+V on normal mode |
12 | :set fileencoding=utf8 | change file encoding |
24 | g[uU] | make lowercase/uppercase |
25 | ! | filter through external program |
27 | g? | ROT13 encoding |
28 | [><] | shift right/left |
29 | zf | define a fold |
35 | [0$] | beginning/end of line |
36 |%% [^|g_] %%| first/last non-blank of line |
37 |%% [g0|g$] %%| beginning/end of screen line |
38 |%% g^ %%| first non-blank of screen line |
39 |%% | %%| go to column |
40 | f<char> | find <char> |
41 | F<char> | find reverse <char> |
42 | t<char> | till <char> |
43 | T<char> | till reverse <char> |
44 | ; | repeat last [fFtT] |
45 | , | repeat reverse last [fFtT] |
51 |%% [gk|gj] %%| up/down screen line |
52 | [-+] |%% same as [kj]^ %%|
59 | W | next WORD (space delimited word) |
60 | [eE] | next end of word/WORD |
61 | [bB] | previous (beginning of) word/WORD |
62 |%% [ge|gE] %%| previous end of word/WORD |
67 | ( | previous sentence |
69 | { | previous paragraph |
70 | } | next paragraph |
71 | ]] | next { in the first column |
72 | ][ | next } in the first column |
73 |%% [[ %%| previous { in the first column |
74 | [] | previous } in the first column |
76 ==== Text Object Selection ====
78 ^ Text Object Selection ^^
79 | [ai][wWsp] | a/inner word/WORD/sentence/paragraph |
80 | a[ or a] | a [] block |
81 | i[ or i] | inner [] block |
82 | [ai][()b] | a/inner () block |
83 | [ai][<>] | a/inner <> block |
84 | [ai]t | a/inner tag block |
85 | [ai][{}B] | a/inner {} block |
86 | [ai]["'`] | a/inner quoted string |
91 | % | next ([{}]), #if, #ifdef, #else, #elif, #endif |
92 | ]) | next unmatched ) |
93 | ]} | next unmatched } |
94 | [( | previous unmatched ( |
95 | [{ | previous unmatched { |
96 | ]m | next start of method |
97 | ]M | next end of method |
98 | [m | previous start of method |
99 | [M | previous end of method |
100 | ]# | next unmatched #else or #endif |
101 | [# | previous unmatched #else or #endif |
102 | ]* or ]/ | next end of a C comment "*/" |
103 | [* or [/ | previous start of a C comment "/*" |
104 | [HML] | top/middle/botton of window |
109 | :map | normal, visual or operator pendind mode |
110 | :map! | insert or command mode |
112 | :map! <C-s> <Esc>:w<CR> | maps Ctrl+S to "escape :w enter" |
113 | ::: |on insert or command mode |
115 ===== Abreviation =====
118 | :ab(breviate) | insert and command mode |
119 | :iab(brev) | insert mode |
120 | :cab(brev) | command mode |
122 | :iab #i #include | changes #i<Space> to #include |
123 | ::: | on insert mode |
125 ===== Window Management =====
128 | vim -o | open each file in a separate window |
129 | :sp(lit) or Ctrl+W,S | split current horizontally |
130 | :vs(plit) or Ctrl+W,V | split current vertically |
131 | :new or Ctrl+W,N | open new horizontally |
132 | :vne(w) | open new vertically |
134 | Ctrl+W,W or Ctrl+(W,W) | iterate through windows |
135 | Ctrl+W,[HJKL] | go to windows on left, down, up, right |
137 | Ctrl+W,= | make all windows equally big |
138 | :res[ize] -N or Ctrl+W,- | decrease height |
139 | :res[ize] +N or Ctrl+W,+ | increase height |
140 | :res[size] [N] or Ctrl+W,_ | set window height |
141 | Ctrl+W,< | decrease width |
142 | Ctrl+W,> | increase width |
143 | Ctrl+W,%%|%% | set width |
145 | Ctrl+W,C | close window |
146 | Ctrl+W,O | close all other windows |
148 ===== Buffer Management =====
151 | :e(dit) <name> | open buffer |
153 | :b(uffer) <num> | switch to buffer <num> |
154 | :sb(uffer) <num> | split windows and switch to buffer <num> |
156 | :ls or :buffers or :files | list buffers |
157 ^ Command Execution ^^
158 | :buffdo | execute command on each buffer |
160 | :bd(elete) | unload buffer |
161 | :bw(ipeout) | unload and delete buffer |
163 ===== Tab Management =====
166 | vim -p | open each file in a separate tab |
167 | :tabe(dit) | open tab |
168 | Ctrl+W,Shift+T | open current window in a new tab |
169 | Ctrl+W,GF | open filename under cursor in new tab |
171 | :tabn(ext) or gt | go to next tab |
172 | :tabp(revious) or gT | go to previous tab |
174 | :tabm(ove) <num> | move to after tab page <num> |
176 | :tabs | list tabs |
177 ^ Command Execution ^^
178 | :tabdo | execute command on each tab |
180 | :tabc(lose) | close tab |
181 | :tabo(nly) | close all other tabs |
185 Use [[http://ctags.sourceforge.net/|ctags]] to generate the tags file.
188 | :ta(g) | jump to tag |
189 | Ctrl+] | jump to tag under cursor |
190 | Ctrl+W ] | split window and go to tag under cursor |
191 | Ctrl+W } | show tag under cursor in preview window |
192 | :pta(g) | show tag in preview window |
193 | Ctrl+T | jump back |
194 | :ts(elect) | list tags that match |
195 | :tj(ump) | :ts that jumps directly when possible |
196 | :sts(elect) | :tselect and split |
197 | g] | Ctrl+] with :tselect |
198 | :tn(ext) | next matching tag |
199 | :tp(revious) | previous matching tag |
200 | :p* | same with preview window |
202 | :tags | list tag stack |
204 | :pc(lose) or Ctrl+W,Z | close preview window |
206 ===== Change List =====
209 | g; | go to previous change |
210 | g, | go to next change |
212 | :changes | list changes |
217 | m<char> | set mark |
219 | ['`]<char> | jump to line/position of mark |
220 | ]' | jump to line next mark |
221 | ]` | jump to position next mark |
222 | [' | jump to line previous mark |
223 | [` | jump to position previous mark |
225 | :marks | list the marks |
230 | Ctrl+O | go to previous jump position |
231 | Ctrl+I or <Tab> | go to next jump position |
233 | :jumps | list jumps |