Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Using VIM as C++ IDE

Anil Shanbhag
November 18, 2011

Using VIM as C++ IDE

Some simple tricks to make VIM work well with C++ code

Anil Shanbhag

November 18, 2011
Tweet

More Decks by Anil Shanbhag

Other Decks in Technology

Transcript

  1. Using VIM as C++ IDE In this short talk I

    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
  2. Multiple windows and buffers One of the nice things is

    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
  3. c.vim  The script : http://www.vim.org/scripts/script.php?script_id=213  This plugin speeds

    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
  4. Cscope  Cscope is a terminal utility which integrates with

    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 ]
  5. Cscope [ Contd. ]  In VIM : Once cscope

    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