Install CTags for VIM
-------------------------------------
sudo apt-get install exuberant-ctags
Install Cscope for VIM
--------------------------------------
sudo apt-get install cscope
Install the following plugins for VIM
------------------------------------------------------------
1. Automatic Display of Declarations in the Context Window on the bottom in the (G)VIM window using the script named 'Source Explorer(srcexpl.vim)' :
http://www.vim.org/scripts/script.php?script_id=21792. Symbol Windows For Each File on the left in the (G)VIM window (G)VIM using the script named 'taglist.vim':
http://www.vim.org/scripts/script.php?script_id=2733. Quick Access to All Files on the right in the (G)VIM window using the script named 'The NERD tree(NERD_tree.vim)':
http://www.vim.org/scripts/script.php?script_id=16584. Cscope maps the keyboard shortcuts for various commands in cscope using the script named '(cscope_maps.vim)':
http://cscope.sourceforge.net/cscope_maps.vim4. Trinity manages all the above plugins and fit them in VIM to get the feel of source insight IDE using the script named '(trinity.vim)':
http://www.vim.org/scripts/script.php?script_id=23474. You can change various options of each plugin in trinity.vim according to you request.
Additonal Info:
-------------------------
After installing cscope its mandatory to build cscope DB for your project inorder to execute the commands inside VIM. If your project is c,cc,cpp project the following command will generate you a basic database. However you can tweak the same for your project requirements. Execute the following command at the top level project directory.
find . -regex '.*\.\(c\|cpp\|h\)$' > cscope.files
cscope -b
the above commands should generate a cscope.out DB file in your current working directory. If successfull, open VIM and type the following command
:cscope add /home/xyz/cscope.out
some useful cscope commands:
- Find this definition - :cs f g
- Find functions called by this function - :cs f d
- Find functions calling this function - :cs f c
- Find this text string - :cs f t
- Find this file - :cs f f
- Find files #including this file - :cs f i
- Find this C symbol - :cs f s
- Find this egrep pattern - :cs f e
- Done and now you are ready to go. Happy VIM'ing.