This repository has been archived by the owner on Dec 24, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME
51 lines (43 loc) · 1.69 KB
/
README
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
If you find yourself reading code without a GUI, this .vimrc will help. It turns on a few features to do with search and code folding. If you've never used Vim before, here's the basic list of commands useful when reading (not editing) code:
Basic movement:
h, j, k, l and arrows - move cursor
b, w, e, B, W, E - move by word
Ctrl-d, Ctrl-u - up and down half screen
Ctrl-f, Ctrl-b - forward and backward full screen
H, L, M - move to top/bottom/middle line of the screen
nnnG - go to line nnn
:nnn - same
G - go to the end of file
gg - go to the start of file
Code navigation:
gd, gD - find local/global symbol definitions
navigation in blocks with % (tomatching bracket), [{, [(, [/ (to outer opening bracket) etc
Opening files:
gf - open file under cursor
'0 - go to previous file (well, buffer)
:e filename - open file
:buffers - list open buffers
:b n - open buffer n
:ba - open windows for all buffers
Windows:
Ctrl-w s - new window above
:sp - same
:vs - new window to the left
My Vimrc maps Shift-up and Shift-down to navigate between (vertically split) windows.
It also maps Ctrl-x to "close window if unmodified" (:q)
Searches:
/regexp - search forward for regexp
?regexp - backward,
n - next resut
* - search for word under cursor
# - same backwards
:vimgrep /pattern/[j][g] file file2... fileN - search in files
:nohl - turn current highlight off
K - look up the word under cursor in man pages. nK - look up in section n, e.g. 5K
Code folding:
zA - toggle fold all for the block containing the current line
(and the whole set: zc, zC, zo, zO, zM, zR, zi)
Undo:
u - undo one change
Shift-u - undo all changes to current line
Even better, use 'view' instead of 'vi' in shell - this always opens files read-only