Custom vimrc

There are plenty of pages all over the internet dedicated to provided an ‘ultimate’ vimrc configuration, and although I don’t claim to have the ultimate configuration – I’m throwing mine into the mix too.

Obviously, the ultimate perfect configuration for me won’t be perfect for you, and everyone will want to do things differently but you can use the following as a rough guide to extend or modify as you wish.

" My vimrc configuration
" =============================================

" Set leader
" =============================================
let mapleader = "-"

" Q and W should act as q and w
" =============================================
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev WQ wq

" For Managing tabs
" =============================================
nnoremap t :tabnew
nnoremap n :tabn
nnoremap p :tabp
nnoremap q :tabclose
nnoremap x :tabonly

" For pasting text
" =============================================
nnoremap  :set invpaste paste?
set pastetoggle=
set showmode

" Auto indentation and tab management
" =============================================
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set autoindent

" Stop swap files being created everywhere
" =============================================
set backupdir=~/.vim-tmp
set directory=~/.vim-tmp

" Searching through document
" =============================================
set ignorecase " Ignore case when searching...
set smartcase " Unless a capital letter is used somewhere
set hlsearch " Highlight matches
set incsearch " Search immediatly

" To remove highlighting having searched
" =============================================
map  :silent :nohlsearch

" Additional Rules
set ruler " Set Ruler
set backspace=indent,eol,start " Make backspace behave correctly
set nu " Display line numbers
set nowrap " Don't wrap
set nocompatible " vi is NOT vim
set scrolloff=5 " 5 lines above/below cursor at all times
syntax on " Turn syntax highlighting on
set t_Co=256 " Force 256 colors
colorscheme wombat " Set colorscheme (It's not actually wombat :o)
set lazyredraw " Makes relativenumbers behave
set undofile
set undodir=~/.vim-undo
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
let g:loaded_matchparen=1

" Powerline stuff
set rtp+=/usr/local/lib/python2.7/dist-packages/powerline/bindings/vim/
set laststatus=2 " Always display status line

Either copy and paste the above into your ~/.vimrc file or download it from here.

Leave a Reply

Your email address will not be published. Required fields are marked *