.vimrc for developers: syntax coloring, indent, mouse, paste

I'm posting here the .vimrc I use for both my desktop computer and my server. It works through SSH too!
It gives the following features to vim:

  • Syntax coloring
  • Dark background every time
  • Highlight search
  • Case insensitive search
  • Autoindent
  • Mouse support (for selecting text, moving cursor)
  • Safe Pasting (Push F2 to activate/deactivate)
  • Always shows current line number


First you need to install either vim-nox (vim with full options but for servers, command-line only) or vim-full (vim with full options plus GUI):

Then edit your ~/.vimrc:

vim ~/.vimrc

and copy and paste this:

set wrap
set nocompatible
syntax on
set background=dark
set autoindent
set ruler
set suffixes=.bak,~,.swp,.o,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
set hlsearch
set textwidth=0
set ignorecase
set mouse=a
 
nnoremap <F2> :set invpaste paste?<CR>
imap <F2> <C-O><F2>
set pastetoggle=<F2>

Save and quit:

:wq

And start vim again, and see the changes!

Leave a comment

Name: (Required)

eMail: (Required)

Website:

Comment: