“Better” Settings
It’s hard to come up with category names for different groups of options, maps, functions, etc… in the vimrc file. There are a number of options in Vim whose default setting doesn’t quite work for me so they gotta change…
" Set the search scan to wrap around the file
set wrapscan
" Set the forward slash to be the slash of note. Backslashes suck
" This is really only applicable to Windows but I like to have a vimrc
" that works no matter what OS I'm currently on
set shellslash
" Make command line two lines high
set ch=2
" set visual bell -- I hate that damned beeping
set vb
" Allow backspacing over indent, eol, and the start of an insert
set backspace=2
" See :help 'cpoptions' for these ones. 'cpoptions' has a huge
" set of possible options
set cpoptions=ces$
" Set the status line the way I like it
set stl=%f\ %m\ %r\ Line:\ %l/%L[%p%%]\ Col:\ %c\ Buf:\ #%n\ [%b][0x%B]
" tell Vim to always put a status line in, even if there is only one
" window
set laststatus=2
" Hide the mouse pointer while typing
set mousehide
" The GUI (i.e. the 'g' in 'gvim') is fantastic, but let's not be
" silly about it :) The GUI is fantastic, but it's fantastic for
" its fonts and its colours, not for its toolbar and its menus -
" those just steal screen real estate
set guioptions=ac
" This is the timeout used while waiting for user input on a
" multi-keyed macro or while just sitting and waiting for another
" key to be pressed measured in milliseconds.
"
" i.e. for the ",d" command, there is a "timeoutlen" wait
" period between the "," key and the "d" key. If the
" "d" key isn't pressed before the timeout expires,
" one of two things happens: The "," command is executed
" if there is one (which there isn't) or the command aborts.
"
" The idea here is that if you have two commands, say ",dv" and
" ",d" that it will take 'timeoutlen' milliseconds to recognize
" that you're going for ",d" instead of ",dv"
"
" In general you should endeavour to avoid that type of
" situation because waiting 'timeoutlen' milliseconds is
" like an eternity.
set timeoutlen=500
" Keep some stuff in the history
set history=100
" These commands open folds
set foldopen=block,insert,jump,mark,percent,quickfix,search,tag,undo
" When the page starts to scroll, keep the cursor 8 lines from
" the top and 8 lines from the bottom
set scrolloff=8
" Allow the cursor to go in to "invalid" places
set virtualedit=all
" For how *I* code these are the best types of settings for
" completion but I get rid of some neat things that you might
" like
set complete=.,w,b,t
" Incrementally match the search. I orignally hated this
" but someone forced me to live with it for a while and told
" me that I would grow to love it after getting used to it...
" turns out he was right :)
set incsearch
" Syntax coloring lines that are too long just slows down the world
set synmaxcol=2048
Adrian:
August 14th, 2010 at 7:30 pm
Just so people know, the cpoptions=ces$ here might screw with plugins that try to map the backslash (snipmate) since it doesn’t include the B option. I have mine set to coptions+=$ so it keeps the defaults and adds the feature we like.
kuddl:
January 31st, 2011 at 1:59 pm
@aadrian : Thank a LOT !!
Mike Bethany:
June 26th, 2011 at 11:19 am
@adrian Thank you! I was getting a “mapping not found” error but that fixed it. Just a minor correction, it’s “cpoptions” not “coptions” but I figured out what you meant. The complete correction would then be:
set cpoptions+=$
Tommy:
January 22nd, 2013 at 11:22 am
set cpoptions=ces$ makes the command ci” for deleting text withing “” not work as you might expect.
Derek Wyatt:
January 22nd, 2013 at 11:26 am
What makes you think it doesn’t work the way I think it should? :) Works just fine for me.