Vim

Vim


This article is Part 3 in a 5-Part Series.


vim

vim is my primary text editor and i use it as an ide for my rails development..Initially you have to spend some considerable amount of time to install vim with all the features enabled and configure it with required plugins but it’s just an one time burden after that your productivity rate will be much higher than any other editor..

Installation

#####Uninstall old vim and install dependencies

  sudo apt-get remove vim vim-runtime gvim 
  
  #On ubuntu  12.04.2 you have to remove these packages as well
  sudo apt-get remove vim-tiny vim-common vim-gui-common
  
  #build dependencies from repository
  sudo apt-get build-dep vim

#####Install lua-5

  curl -R -O http://www.lua.org/ftp/lua-5.2.2.tar.gz
  tar zxf lua-5.2.2.tar.gz
  cd lua-5.2.2
  make linux test
  sudo cp src/lua /usr/local/bin/lua
  sudo cp -r src /usr/local/include/

#####Install luajit

  sudo apt-get install luajit libluajit-5.1

#####Download latest vim

  wget ftp://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz2
  tar -xvjf  vim-7.4.tar.bz2
  cd vim74

#####Apply patch to make vim work with lua and luajit

  curl https://gist.github.com/shirosaki/5663617/raw | patch -p1
Compile and install vim
./configure \
    --enable-perlinterp=dynamic \
    --enable-pythoninterp=dynamic \
    --enable-rubyinterp=dynamic \
    --enable-luainterp --with-luajit --with-lua-prefix=/usr/local \
    --enable-cscope \
    --enable-gui=auto \
    --enable-gtk2-check \
    --enable-gnome-check \
    --with-features=huge \
    --with-x \
    --with-python-config-dir=/usr/lib/python2.7/config

    make VIMRUNTIMEDIR=/usr/share/vim/vim74
    sudo make install

#####check vim version

  vim --version

Some useful plugins

vim as rails ide.

Sample vimrc configurations

  source ~/dotfiles/vim-config/bundles.vim
  source ~/dotfiles/vim-config/key-bindings.vim

  "setting goes here
  syntax on
  syntax enable
  set relativenumber
  filetype plugin indent on 
  set noswapfile
  set incsearch
  set ignorecase
  set history=1000
  set title
  set expandtab
  set autoindent
  set mouse=a
  set spell
  set cursorline
  set clipboard=unnamed
  set backspace=indent,eol,start " Make backspace behave normally.
  set wildmode=list:longest,full
  set wildmenu
  set tabstop=2 shiftwidth=2 softtabstop=2
  set dictionary-=/usr/share/dict/words dictionary+=/usr/share/dict/words

  "Rails vim key-mappings
  nnoremap <leader>rr :e config/routes.rb<CR>
  nnoremap <leader>rv :Rview<space>
  nnoremap <leader>rc :Rcontroller<space>
  nnoremap <leader>rg :Rgenerate<space>
  nnoremap <leader>rx :Rextract<space>
  nnoremap <leader>rm :Rmodel<space>
  nnoremap <leader>rs :Rstylesheet<space>
  nnoremap <leader>rj :Rjavascript<space>
  nnoremap <leader>ge :e Gemfile<CR>

  "shougo's plugins
  NeoBundle 'Shougo/neocomplete'
  NeoBundle 'Shougo/neosnippet'

  "tpope's plugins
  NeoBundle 'tpope/vim-fugitive'                     "git inside vim
  NeoBundle 'tpope/vim-repeat'                       "Helps to repeat previous command with . key
  NeoBundle 'tpope/vim-endwise.git'                  "To enable automatic end in loops

  " All scrooloose plugins  
  NeoBundle "scrooloose/syntastic"                   "to highlight syntax
  NeoBundle 'scrooloose/nerdcommenter'               "to autocommenting based on file type
  NeoBundle "scrooloose/nerdtree"                    "classic file explorer

  "Syntastic customization
  let g:syntastic_error_symbol = '✗'
  let g:syntastic_style_error_symbol = '✠'
  let g:syntastic_warning_symbol = '∆'
  let g:syntastic_style_warning_symbol = '☢'

check my dotfiles repo for more configurations..