Hame Page

index

Format source code

gg=G

Colorscheme

colorscheme is in "/usr/share/vim/vimXX/colors/"

jeffy's vim plugin

http://code.google.com/p/jeffy-vim/

fx OR Fx

The former will move cursor to first 'x' rightside of current position.
The latter will move cursor to first 'x' leftside of current position.

Screen Scroll

<C-E> <C-Y> | <C-D> <C-U> | <C-F> <C-B>
zz, zt, zb

Enable mouse select and copy to clipboard

set mouse=v

(Block) Indent

< or >

Switch windows

<C-h, j, k, OR l>

Jump to the matching bracket

%

substitute word(s)

:s/vivian/sky/
Replace the first "vivian" of current line with "sky"
:s/vivian/sky/g
Replace all "vivian" of current line with "sky"
:n,$s/vivian/sky/
Replace the first "vivian" in each line from the nth line to the last with "sky"
:n,$s/vivian/sky/g
Replace all "vivian" in each line from the nth line to the last with "sky"
(n is a numeric, if n is ".", means from the current line to the last.)
:n,ms/vivian/sky/g
Replace all "vivian" in each line from the nth line to the mth line with "sky"

Change DOS ending to UNIX

:e ++ff=unix
:%s/\r//g
:w ++ff=unix

Change Syntax Highlight Mode Manually

:set syntax=cpp

Batch Rename Files

for fn in `ls *.ino`; do new=${fn%%ino}cpp; echo $fn $new; done

Suspend VIM to Shell, then Resume

Turn to shell, in vim:

Ctrl + z

Resume to vim, in shell:

$ fg

Use cscope to Add Specific Source Files and Headers

$ cscope -Rb -I Common/include/ -I BDP_CEC_Feature/include/ BDP_CEC_Feature/source/BDP_cec.c

Or multiple files & headers:

$ find PE/ Common/ -name '*.c' -o -name '*.h' > cscope.files
$ cscope -b
(or specify explicitly: cscope -i cscope.files)

Jump to the Header File under Cursor

:set path+=.\**
gf