Showing posts with label Vim. Show all posts
Showing posts with label Vim. Show all posts

Vi & Vim Tutorial

cite:
http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html


:set wrap
:set nowrap

Replace all string in document



  • : %s / ______________ /\ ________________/ g

Set tab spaces

1. vim /etc/vim/vimrc
2. set ts=4


利用字串取代('^M' 要用 Ctrl+V 不要放開 Ctrl 再按 M 才能打出來喔!)
   :%s/^M/\r/g


Display the line number in vim



  1. vim /etc/vim/vimrc
  2. :set number


Foreground and Background Switch

1) Ctrl + z
2) fg ....
http://arjanvandergaag.nl/blog/foreground-and-background-processes.html

Set current line highlight

set cursorline
hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white
hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white

lightmagenta darkgray lightgrey darkgrey lightgreen lightgray darkmagenta gray white red grey darkred brown darkblue darkgreen lightblue yellow cyan

Folding codes in vim

1. visual select the codes (v) (ctrl+v)
2. zf
3. za

相關文件

使用 cscope + ctags + taglist 來閱讀sourcecode

ctags + taglist

1) Install ctags

$   sudo apt-get install exuberant-ctags

2)Download and install taglist
https://sourceforge.net/projects/ctags/files/
http://vim-taglist.sourceforge.net/

$   unzip taglist_45.zip
#it will generate plugin and doc

$   mv plugin/   ~/.vim
$   mv doc/   ~/.vim

3)turn on/off the taglist in vim

$   sudo vim /etc/vim/vimrc

Add the following line:

map <f9> :Tlist<CR>


4)check the target directory and create the tags

$   ctags -R *.c *.h

OR

$   find 'pwd' -type f -name "*.[ch]" -o -name "*.cc" -o -name "*.[sS]"  | sed -e 's/^/"/' -e 's/$/"/' | xargs /usr/bin/ctags -a

5)Open the vim and press F9
#The window will divide by two part, use the Ctrl-W-W to switch the window
#The left window: Jump to the correspond function or definition
#The right window:
   Ctrl+]:Jump to function implement position, the cursor should be the function name's front
   Ctrl+t:return to the original position

cite:http://stenlyho.blogspot.com/2008/11/ubuntuvim-plugin-ctagstaglist.html

Cscope




Call Graph
CCTree: http://www.vim.org/scripts/script.php?script_id=2368