My Vim Configuration

July 29, 2017

I’ve just used Vim when I write code for about 6 months and I am still using it. In this post, I’m gonna write about my favorite Vim configs and plugins.

I’m using Vundle for plugin management. Vundle helps me to make easy plugin installation and update.

Abbreviations

When I write code in Vim I sometimes write the wrong command for close the file. For example, I write “Wq” instead of “wq”. I’ve discovered abbreviations for this situation.. Here are my abbreviations:

cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall

Relative Line Numbers

One of my favorite features at Vim is “relative line numbers”.

vim-relative-numbers

Relative line numbers help us to edit our file quickly. For example, if we want to move up or down 5 lines from the current line, we just need use “10j” or “10k”.

set number
set relativenumber

Shortcuts

To create shortcut you can find a great tutorial in vim.wikia. Here are my favorite shortcuts:

"" Split
noremap <Leader>h :<C-u>split<CR>
noremap <Leader>v :<C-u>vsplit<CR>

"" Tabs
nnoremap <Tab> gt
nnoremap <S-Tab> gT

My Favorite Plugins

I’m using many plugins. These plugins provide a better vim for me. I generally write php, html, css, basic javascript and ruby.

Here are plugins I’m using for these languages:
  • stanangeloff/php.vim
  • jelera/vim-javascript-syntax
  • hail2u/vim-css3-syntax
  • tpope/vim-rails
  • tpope/vim-rake
  • thoughtbot/vim-rspec
  • ecomba/vim-ruby-refactoring
Other plugins:
  • scrooloose/nerdtree
  • ctrlpvim/ctrlp.vim
  • airblade/vim-gitgutter
  • vim-airline/vim-airline
  • grep.vim
  • tomasr/molokai

I tried to write about my favorite the vim configurations. I guess the article has been short but I wanted to write basic configurations. I hope there is no wrong information. Maybe I’ll add some new information in the near future.

You can find my .vimrc file on GitHub.

Comments

comments powered by Disqus