Conditional .vimrc configs

no comments yet, post one now

This is new to me, but probably old hat to vim regulars. You can have conditional statements in your vimrc config depending on which machine you are working on. In this case I have disabled end of line white space cleaning on my ‘calcifer’ and ‘alderann’ machines.

" get hostname
let machine = substitute(system('hostname'), "\n", "", "")
" auto strip whitespace when saving
" don't auto strip on these machines
if machine !~ "[calcifer|alderann]"
  autocmd BufWritePre * :%s/\s\+$//e
endif

I’ve taken to sharing my development workbench and vim configuration across multiple machines and this comes in really handy.

December 21, 2011 10:11 by

no comments yet, add yours below

Leave a comment