The purpose of this blog is to happily share my learning and ideas to help people, who actively seek solutions for the day-to-day problems faced.

Recent Posts

vim - Plugin Installation

A common problem to most of the developers out there while developing their code is formatting, they should follow a proper coding standards and styles before commit their code in any version control system. Today we are going to see how we can simplify this process by adding plugin to the most famous vim editor.

vim


Before installing plugin in vim, let us install the git.

To install git:

yum install git

After installing the above prerequisite, following are the step by step instructions to install vim plugin,
  1. Clone git plugin repository
  2. Adding contents to .vimrc file
  3. Plugin Installation
  4. Verification

Clone git plugin repository:

Simple, you just need to clone some existing plugin packages. Here I am sharing one of the famous plugin manager "Vundle" which is a short form for Vim bundle

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

Adding contents to .vimrc file

Once the plugin repository is cloned, we should add the below contents into .vimrc file. (Note: Be careful, just add only the commands which you need)

set nocompatible              " required
filetype plugin on            " required

" set the runtime path to include Vundle and initialize
 set rtp+=~/.vim/bundle/Vundle.vim
 call vundle#begin()
"
" " alternatively, pass a path where Vundle should install plugins
" "call vundle#begin('~/some/path/here')
"
" " let Vundle manage Vundle, required
 Plugin 'gmarik/Vundle.vim'
"
" " Add all your plugins here (note older versions of Vundle used Bundle
" instead of Plugin)
"
"
" " All of your Plugins must be added before the following line
 call vundle#end()            " required
 filetype plugin indent on    " required
 nnoremap <C-J> <C-W><C-J>
 nnoremap <C-K> <C-W><C-K>
 nnoremap <C-L> <C-W><C-L>
 nnoremap <C-H> <C-W><C-H>
 nnoremap <space> za
 au BufNewFile,BufRead *.py
\ set tabstop=4 |
\ set softtabstop=4 |
\ set shiftwidth=4 |
\ set textwidth=79 |
\ set expandtab |
\ set autoindent |
\ set fileformat=unix |
 Plugin 'vim-scripts/indentpython.vim'
 set encoding=utf-8
 Plugin 'scrooloose/syntastic'
 Plugin 'nvie/vim-flake8'
 let python_highlight_all=1
 syntax on
 Plugin 'jnurmine/Zenburn'
 Plugin 'altercation/vim-colors-solarized'
 if has('gui_running')
   set background=dark
   colorscheme solarized
 else
   colorscheme zenburn
 endif

 call togglebg#map("<F5>")
 Plugin 'scrooloose/nerdtree'
 let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree
 Plugin 'kien/ctrlp.vim'
 "set nu
 Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
 set clipboard=unnamed
 Plugin 'jistr/vim-nerdtree-tabs'
 let NERDTreeIgnore=['\.pyc$', '\~$']
 map <C-n> :NERDTreeToggle<CR>
 let g:ctrlp_map = '<c-p>'
 " copy and paste
 vmap <C-c> "+yi
 vmap <C-x> "+c
 vmap <C-w> c<ESC>"+p
 imap <C-w> <ESC>"+pa
 Plugin 'leshill/vim-json'
 autocmd FileType python map <buffer> <F3> :call Flake8()<CR>

 "Plugin 'reedes/vim-lexical'
 "let g:lexical#spellfile = ['~/.vim/spell/en.utf-8.add',]
 "let g:lexical#spelllang = ['en_us',]
 "augroup lexical
 "          autocmd!
 "          autocmd FileType markdown,mkd call lexical#init()
 "          autocmd FileType textile call lexical#init()
 "          autocmd FileType python call lexical#init({ 'spell': 1 })
 "augroup END
 "
 "Plugin 'Valloric/YouCompleteMe' 

Plugin Installation
  1. Login into your linux machine terminal and type 
    • vim
  2. After entering into vim type
    • :PluginInstall
  3. PluginInstall will take care of installing all the plugins we mentioned in the .vimrc file, once all the plugins are installed just type :q to exit from the buffer window
    • :q

Verification

Just to make sure that everything works fine, open your vim editor and start writing your code and you could see that your plugin installation and its features are working fine as expected.

Cheers.

No comments