Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to make my gVim installation as portable as possible, and in doing so I want to put the _viminfo file in the $VIM directory rather than $HOME. I'm pretty new to hacking vimrc configurations, but here's what I've been trying:

let viminfopath=$VIM."\\_viminfo"
execute "set viminfo='1000,n".escape(viminfopath, ' ')

" Some other portability stuff.
set nobackup
set nowritebackup
if has("win32") || has("win64")
    set directory=$TMP
    set directory=~/tmp

This doesn't seem to be working, though; does anyone have any tips?


Edit: running :echo viminfopath gives the result F:\Programs\Vim\_viminfo, so the path itself is valid at least. It must be the execute operation that's not working.

share|improve this question
up vote 1 down vote accepted

You can use amix's suggestions: (I know the MySys approach can be done in different and better ways, but I think you can get the idea)

fun! MySys()
  return "windows"

set runtimepath=~/vim_local,$VIMRUNTIME
source ~/vim_local/vimrc

$VIMRUNTIME is the approach here, really interesting. Check amix's vimrc as well, there are some cross-plataform tips to get you started.

share|improve this answer

I'm thinking that if you use a backslash as your directory separator, you're going to break anything that isn't Windows.

let viminfopath=$VIM."\\_viminfo"

I would shoot for

let viminfopath=$VIM."/_viminfo"

instead. That should work in Windows as well as anything else.

Granted, that's a guess, but it's where I'd start.

share|improve this answer
Tried this but it didn't work. Thanks though. – Will Vousden Mar 23 '10 at 19:00 (This comment was from a deleted exact duplicate of this answer.) – accolade Jan 17 '12 at 1:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.