maio
[h2N7SspZmY.git] / data / pages / vim / commands.txt
blob32e6f6ad60259679d3faf1125e6efd3118991e31
1 ====== Vim Commands ======
3 ===== Modes =====
5 ^ Modes    ^^
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 |
11 ^ Miscelaneous ^^
12 | :set fileencoding=utf8 | change file encoding |
14 ===== Motion =====
16 ==== Operators ====
18 ^ Operators ^^
19 | c | change |
20 | d | delete |
21 | y | yank |
22 | ~ | swap case |
23 | g~ | swap case |
24 | g[uU] | make lowercase/uppercase |
25 | ! | filter through external program |
26 | = | indent |
27 | g? | ROT13 encoding |
28 | [><] | shift right/left |
29 | zf | define a fold |
31 ==== Left-Right ====
33 ^ Left-Right ^^
34 | [hl] | left/right |
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] |
47 ==== Up-Down ====
49 ^ Up-Down ^^
50 | [kj] | up/down |
51 |%% [gk|gj] %%| up/down screen line |
52 | [-+] |%% same as [kj]^ %%|
53 | G | go to line |
55 ==== Word ====
57 ^ Word ^^
58 | w | next word |
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 |
64 ==== Text Object ====
66 ^ Text Object ^^
67 | ( | previous sentence |
68 | ) | next 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 |
88 ==== Others ====
90 ^ Others ^^
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 |
106 ===== Map =====
108 ^ Types  ^^
109 | :map            | normal, visual or operator pendind mode |
110 | :map!           | insert or command mode |
111 ^ Example  ^^
112 | :map! <C-s> <Esc>:w<CR> | maps Ctrl+S to "escape :w enter" |
113 | :::                    |on insert or command mode |
115 ===== Abreviation =====
117 ^ Types ^^
118 | :ab(breviate)  | insert and command mode  |
119 | :iab(brev) | insert mode |
120 | :cab(brev) | command mode |
121 ^ Example ^^
122 | :iab #i #include | changes #i<Space> to #include |
123 | :::              | on insert mode |
125 ===== Window Management =====
127 ^ Creation ^^
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 |
133 ^ Navigation ^^
134 | Ctrl+W,W or Ctrl+(W,W) | iterate through windows |
135 | Ctrl+W,[HJKL] | go to windows on left, down, up, right |
136 ^ Resizing ^^
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 |
144 ^ Destruction ^^
145 | Ctrl+W,C | close window |
146 | Ctrl+W,O | close all other windows |
148 ===== Buffer Management =====
150 ^ Creation ^^
151 | :e(dit) <name> | open buffer |
152 ^ Navigation ^^
153 | :b(uffer) <num> | switch to buffer <num> |
154 | :sb(uffer) <num> | split windows and switch to buffer <num> |
155 ^ Status ^^
156 | :ls or :buffers or :files | list buffers |
157 ^ Command Execution ^^
158 | :buffdo | execute command on each buffer |
159 ^ Destruction ^^
160 | :bd(elete) | unload buffer |
161 | :bw(ipeout) | unload and delete buffer |
163 ===== Tab Management =====
165 ^ Creation ^^
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 |
170 ^ Navigation ^^
171 | :tabn(ext) or gt | go to next tab |
172 | :tabp(revious) or gT | go to previous tab |
173 ^ Organization ^^
174 | :tabm(ove) <num> | move to after tab page <num> |
175 ^ Status ^^
176 | :tabs | list tabs |
177 ^ Command Execution ^^
178 | :tabdo | execute command on each tab |
179 ^ Destruction ^^
180 | :tabc(lose) | close tab |
181 | :tabo(nly) | close all other tabs |
183 ===== Tags =====
185 Use [[http://ctags.sourceforge.net/|ctags]] to generate the tags file.
187 ^ Navigation ^^
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 |
201 ^ Status ^^
202 | :tags | list tag stack |
203 ^ Destruction ^^
204 | :pc(lose) or Ctrl+W,Z | close preview window |
206 ===== Change List =====
208 ^ Navigation ^^
209 | g; | go to previous change |
210 | g, | go to next change |
211 ^ Status ^^
212 | :changes | list changes |
214 ===== Marks =====
216 ^ Definition ^^
217 | m<char> | set mark |
218 ^ Navigation ^^
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 |
224 ^ Status ^^
225 | :marks | list the marks |
227 ===== Jumps =====
229 ^ Navigation ^^
230 | Ctrl+O | go to previous jump position |
231 | Ctrl+I or <Tab> | go to next jump position |
232 ^ Status ^^
233 | :jumps | list jumps |