Skip to content
This repository has been archived by the owner on Dec 24, 2017. It is now read-only.

agelastic/vim-reading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

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

About

My Vim config for code reading

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published