Monday, September 2, 2013

Tip: Vim Config Files on Windows

On Windows, Vim's config files appear to be stored/read from:
C:\Users\%UserName%\AppData\Local\VirtualStore\Program Files\Vim

Unlike on Linux, simply placing a ".vimrc", or a "_vimrc" in your "Home" directory (aka C:\Users\%UserName%\) has no effect.

In recent years, I've increasingly been using Vim as my "quick edits" + "occasionally used lightweight text editor" (mainly since my two other primary text editors now often have several full sets of files open for various large ongoing projects, making it somewhat inconvenient to use them again for quickly checking on things here and there).

From time to time, it's necessary to edit the Vim config file to add some or other setting to combat some or other annoying caveat about its default behaviours (for the record, I currently haven't eliminated all of 'em yet - notably the indent preservation problem). However, remembering where exactly this is stored each time is a bit of a pain. Hence this post.


As a side note, here are some things I've currently got enabled...

For general usage:
" indention
":set cpoptions += I
set autoindent
set indentexpr=GetIndent()

function GetIndent()
   let lnum = prevnonblank(v:lnum - 1)
   let ind = indent(lnum)
   return ind

" tabs must be used, and of size 4
set ts=4
set sw=4        " shiftwidth sounds like it will insert spaces... otherwise make this 4
set pi            " preserve indent always

" nicer search behaviour
set ignorecase  " can do lowercase queries
set smartcase   " typing with some uppercase won't screw things up
set incsearch   " jumps to matches as you type - seems to be default already

" line numbers
set number      " line numbers are always shown

set backupdir=~/vim_tmp   " it sucks to have to keep cleaning up temp files all over the show...

And, something that is necessary on Windows (since the default font used in GVim is a hideous 8bit monstrosity):
set gfn=Consolas:h10:cANSI

(while usually I'm used to seeing code in Courier, for Vim, Consolas seems to fit better with the overall lightweight + chunky-90's "programmer UI" aesthetic that it has ;)

No comments:

Post a Comment