Code reading with Ctags and Vim
Ctags is useful code reading tool. Here, search a class or function from source codes in Vim.
Go to path of source and run ctags -R :
cd ~/path/to/source ctags -R
Now, 'tag' is created in the current directory.
To read the tag file when vim starts, edit .vimrc :
Add following lines :
" ctags set tags=./tags,~/path/to/source/tags
Then start vim. If you want to find out a class or function under the cursor, press Ctrl+] and jump to the position in which the class or function is defined.
Tips to use ctags with vim:
- If there are two or more candidates, press g, Ctrl+] and choose the destination to jump.
- Go back to previous position, press Ctrl+t or Ctrl+o, or run :pop.
- Press C-w} to open preview window.
- Press C-wC-z or :pc to close the preview window.
- Run :tags to check the destination before jumping.