-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheat_sheet
More file actions
executable file
·255 lines (202 loc) · 7.74 KB
/
cheat_sheet
File metadata and controls
executable file
·255 lines (202 loc) · 7.74 KB
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
---------------------------------------------Insert mode------------------------------------------------------
Esc - puts in normal mode
,, - move out of brace
;; - move to end of line put ; and stay in insert mode
:: - move to end of line put : and then insert mode on next line
.. - move out of current line and put insert mode next line
Ctrl + j - Get out of braces
Ctrl + x - then Ctrl + p/n for autocomplete
Ctrl + x - then Ctrl + l for line compelete
+arrow keys
right -
left - copy current line and put in normal mode on next line
up- NW get out of current line and put { on same line and get in insert mode in between braces
down- NW get out of current line and put {} on next line and get in insert mode in between braces
--------------------------------------------------------------------------------------------------------------
---------------------------------------------Normal mode------------------------------------------------------
; - repeats last movement
. - repeats last done
:n - go to nth line
gg - top of file
G - end of file
Ctrl + U - scroll half page up
Ctrl + D - scroll half page down
Ctrl-B page up
Ctrl-F page down
zz scroll the line with the cursor to the center of the screen
zt scroll the line with the cursor to the top
zb scroll the line with the cursor to the bottom
Shift + h - beginning of line (same as 0)
Shift + k - end of line(same as $)
tab - move between matching braces
+Easy motion
,w - easy motion word
,b - backward motion word
,f - char motion forward
,s - char motion backward
w - forward to beginning of word
W - Forward to beginning of WORD (limited by whitespace)
b - Backward to beginning of word
B - Backward to beginning of WORD
e - Forward to end of word
E - Forward to end of WORD
f<char> - forward to char
F<char> - backward to char
t<char> - forward to char not including char
T<char> - backward to char not including char
h - move left. Eg. 7h moves 7 positions to left
j - move down
k - move up
l - move right
*Folds
space - toggles fold
zR - open all folds
zM - close all folds
dd - delete a line
D - delete everything on right side
dw- delete word ndw - deletes n words
diw - delete inner word - when in middle of word
/ - search , enter search item and press enter use n/N for go through search results
n - next searched
N - previous searched
* - search word under cusror
g*- search without match whole word
Replace - TODO
u - undo
Ctrl+ r - redo
,u - undo tree timestamped changes
,c - copy complete line in reg a
,v - paste above current line from reg a
,a - select entire file
p - paste with indentation auto corrected in c file
P - Paste before cursor
Yank in register. First select or yy then "ay
"ay - yank in register a
"ap - paste from register a
y - yank
yy - copy entire line. 3yy copies 3 lines
yw - yank word (same as ,v)
yiw - yank inner word (same as ,c)
,p - normal paste
Uppercase Lowercase inner word
g^ Upper case
gv Lower case
,x - put a new line above stay in normal mode
,z - put a new line below stay in normal mode
+Surround
In normal mode
ds" - deletes "" around
cs]} - change [] to {}
ysiw" - quotes with "
In visual mode - S" - surrounds with "" i.e vS"
+Comments
,c+space - toggle comment
,cc - comment
,cs - sexy comment
,cu - uncomment
,tt - toogle tagbar panel
Ctrl + ] - Jump to function definition
Ctrl + o - last edit location
Ctrl + i - next edit location
Ctrl + h - move to left tab
Ctrl + l - move to right tab
Ctrl + j - move to down tab
Ctrl + k - move to upper tab
i - insert before
I - insert at first non whitespace character
a - insert after
A - insert end of line
o - insert mode on line below
O - insert mode on line above
s - delete charater and insert mode
S - delete entire line and insert mode
c- change e.g ctw - , ciw - change innner word, cw - change word
ct<w> - change till w and put in insert mode
ciw - change word when inside it
cw - change word when at start of it
C - inserts and clears rest of line to right
r - replace single char
R - replace mode
+arrow keys
right - insert blank line
left - copy line and paste above and put in normal mode. Use 4<rightkey> to copy 4 below lines(including current line) and paste above current line.
up - shift current line up
down - shift current line down
---------------------------------------------------------------------------------------------------------
---------------------------------------------Visual mode-------------------------------------------------
v - visual mode
Shift + v - Visual line mode
Ctrl + v - Block visual mode. Use I to insert then escape. Applies to all block
gg Shift + v G - Selects entire file
In visual mode - S" - surrounds with "" i.e vS"
Select lines then shift < or > to shift code
,c - copy selection in reg a
,v - paste from reg a same as right arrow key
,x - cut selection into reg a
left -
right - paste from reg a
up - shift selected lines up
down - shift selected line down
---------------------------------------------------------------------------------------------------------
--------------------------------------------Command mode-------------------------------------------------
:noh - no highlight
+Buffers
:ls - list buffers
:b # - move to buf # (buffers are listed at bottom)
:bn - next buffer. Also can be used to switch between tabs
:bp - previous buffer
:!<command> - runs bash command then return back to vim. E.g :!pwd, :! wc % (This will display word count of present file)
:! ctags -R . On nerdtree window use cd to change directory on that window itself use ctags or create new files.
:pwd - prints directory of current file
* ctags
:set tags - display current tags file path
:set tags=/path/to/tags - set tags file path. Set it absolute path for fast tags search otherwise vim will find tags file upto to
root which is slow. E.g :set tags=/nobackup/tsheoran/dev/oct12/calvados/tags
+Macros
:q<char> - Starts recording
:q stops recording
@<char> - execute n@<char> n times macro <char> run
---------------------------------------------------------------------------------------------------------
*File finder
Ctrl + p - fast file finder
*Function keys
F1 - delete current file
F5 - cscope update. Make sure set cd to root. Use nerdTree window for this.
F6 - Create function comment
F7 - create enum header
F8 - create comment header
*nerdTree
Ctrl + e - Open/Close nerdtree
cd - change working directory to directory under cursor
C - set root of tree to directory under cursor
o - open
i - horizontal split
s - vertical split
B - open bookmark
Bookmark <name> - bookmark under cursor
r - refresh current directory
R - refresh root
* cscope
# Open vim from directory where cscope.out file is. This will cause cscope add on startup. Otherwise set $CSCOPE_DB var to appr
opriate path before opening vim. E.g export CSCOPE_DB=/nobackup/tsheoran/dev/oct12/calvados/. Another option just open one tab
with vim from base directory use F5 in this tab. Use other tab for work.
# Refresh database. Use F5. But CWD should be where cscope.out is needed. Use nerdTree to reach that folder then cd. in nerdtree window
F5. if cscope.out is not present, it will create it. To check current working directory :pwd
# In normal mode
Keys
Ctrl+\ - same window
Ctrl+space - horizontal spilt
Ctrl+space + Ctrl+space - vertical split
then
s symbol: find all references to the token under cursor
g global: find global definition(s) of the token under cursor
c calls: find all calls to the function name under cursor
t text: find all instances of the text under cursor
e egrep: egrep search for the word under cursor
f file: open the filename under cursor
i includes: find files that include the filename under cursor
d called: find functions that function under cursor calls
* CCtree
:CCTreeLoadDB
<C-\>< Get reverse call tree for symbol
<C-\>> Get forward call tree for symbol