am going to cover how to make better use of VIM while programming in c++ . Operating multiple windows and working with buffers c.vim plugin Cscope plugin
buffers :open – opens the file in the current window :split – splits horizontally into 2 windows :vsplit – splits vertically into two windows :ls – view all currently open buffers :b <no> - open buffer <no> in current window
up writing new code considerably. It has many predefined code snippets for almost all tasks like main , function , try catch block . It prints out templates which create a professional appearence . Eg: \if – Insert a new function : creates a block of code containing fields for name , description in comments and a stub for function Keystrokes defined for compiling and runnning programs programs : \rc – compile the program \rr – run the program :h csupport – to view the complete do:cumentation
vim by default . Cscope is very useful for browsing C/C++ source code . $sudo apt-get install cscope $cscope -R : This builds the cscope.out covering all subdirecteries under cur dir and opens the ui . [ Remember CTRL-D to quit and CTRL-TAB to switch ]
installed you can directly call the csope commands :cscope find symbol <s> (or in short) :cs f s <s> Additionally you can add the script http://cscope.sourceforge.net/cscope_maps.vim which defines some keyboard mappings. CTRL \ + s – find the symbol CTRL spacebar + s – split window CTRL spacebar spacebar + s – vsplit window g – global defn , c – calls to function s – symbol , f – file