Showing posts with label vim. Show all posts
Showing posts with label vim. Show all posts

Sunday, March 28, 2010

Vim, GDB

In this aspect, Emacs has a better GDB interface. The best interface for using GDB with vim seems to be the clewn project. The installation is fairly easy. This page describes the process of installing and using gdb with vim. However, Clewn works only with gvim and not with vim. If you are using vim on a console, you need to recompile vim with vimgdb patch. The process is described on the Clewn webpage. You can click here . This option is little cumbersome as one has to download the source and compile it with the vimgdb patch. Since I like gvim, I prefer to use clewn.

Thursday, March 25, 2010

VIM, auto Completion

IF you are only interested in auto-completing long words as you type, then you look here.   Basically it says :

The function A_Very_Long_Function_Name() can be quite exasperating to type over and over again. While still in insert-mode, one can auto-complete a word by either searching forwards or backwards. In function, Another_Function() one can type A_Very... and hit CTRL-P. The first matching word will be displayed first. In this case it would be A_Very_Long_Variable_Name. To complete it correctly, one can hit CTRL-Pagain and the search continues upwards to the next matching word, which is A_Very_Long_Function_Name. As soon as the correct word is matched you can continue typing. VIM remains in insert-mode during the entire process.




However, if you are interested in having declarations for all functions available in C++ or in a library, you need to use ctags.  A very good explanation of the process to set it up is available here. It is quite long. I would just enumerate the steps for the sake of brevity. I tried it on both Debian 5.0 and Ubuntu 9.10 and it works perfectly. 


  1. Install exuberant-ctags

    $ sudo apt-get install ctags

  2. Download omnicppcomplete package and extract the zip file into your ~/.vim/ folder. After this .vim folder should look something like this. It may contain other folders depending on the original content of your .vim folder. IF you don't have a .vim folder in your home directory, then create now.

    $ cd ~/.vim
    $ ls
    after  autoload  doc  ftplugin omnicppcomplete-0.41.zip

  3. Generate tags for C++ . ctags generates a file called "tags". You should rename it to something like "cpp.tags". You can have different such files for different libraries.

    $ ctags -R --c++-kinds=+p --fields=+iaS --extra=+q /usr/include/c++
    $ mv tags cpp.tags
  4. Now add following lines to ~/.vimrc file

    set tags+=~/.vim/cpp.tags
    set nocp
    filetype plugin on
    map  :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .

    Last command maps CTRL-F6 to generate tags in the current directory directly from vim editor.

  5. Open Vim and run following command to see the help files related omnicomplete.

    :helptags $HOME/.vim/doc
    :h omnicppcomplete


Monday, August 10, 2009

Vim-latex suite on Ubuntu Jaunty

First install vim-latex package using synaptic packet manager. Then run following command on a terminal :

$ sudo vim-addons -w install latex-suite

Now opening a tex document with gvim should show tex related menus on the menu bar.

If this does not help, then refer to ubuntu forums for solution. For instance check this link.