4

I have gVim 7.4.608 installed on Windows 7 at work.

I've looked in C:\ , C:\Users\<username>\AppData , C:\Program Files\vim , C:\Temp but there's no sign of it. It must exist somewhere, command history is working OK. I just want to read the file, I don't care where it actually is.

From :help viminfo

The default name of the viminfo file is "$HOME/.viminfo" for Unix and OS/2,
"s:.viminfo" for Amiga, "$HOME\_viminfo" for MS-DOS and Win32.  For the last
two, when $HOME is not set, "$VIM\_viminfo" is used.  When $VIM is also not
set, "c:\_viminfo" is used.  For OS/2 "$VIM/.viminfo" is used when $HOME is
not set and $VIM is set.

The variables %HOME% and %VIM% were not set in my Windows environment.

I couldn't look in directory C:\Users\<username>\Application Data.

3
  • 1
    Why are you looking for that file?
    – romainl
    Apr 8, 2015 at 7:08
  • Wanted to grab some stuff out of the command history
    – roblogic
    Apr 8, 2015 at 15:15
  • 2
    @ropata q: is very helpful for this, it gives you a Vim buffer allowing you to search, edit, etc your command history.
    – akshay
    Apr 9, 2015 at 1:41

3 Answers 3

6

For Windows, the home directory is set in %USERPROFILE%. I believe vim will use this as $HOME.

In my case, the _viminfo is located in the C:\Users\<username>, which is the home directory, while the %HOME% is not set as well.

3
  • 1
    It was indeed in C:\Users\<username>\_viminfo. The command :echo $HOME works a charm as well.
    – roblogic
    Apr 8, 2015 at 15:18
  • 1
    @ropata The command echo $HOME only works in the PowerShell, not in the cmd. But maybe no one is using cmd anymore? :D
    – Tony LIU
    Apr 9, 2015 at 1:45
  • thanks for the Powershell tip, I called echo $HOME from the vim command line with the same result.
    – roblogic
    Apr 9, 2015 at 20:35
1

Are you sure the HOME variable isn't set? I have encountered cases where ENV was not set, but HOME always seems to be assigned a value in my (G)Vim instances.

If you type echo $HOME in command mode, Vim should display what value is set for HOME. Alternatively, you can try e $HOME\.viminfo and see if this opens the contents of the .viminfo file. If this is the case, you have found it!

2
  • 1
    Except it will be _viminfo, not .viminfo, in WIndows.
    – jamessan
    Apr 8, 2015 at 13:45
  • This answer clarifies why I can't find or $HOME or %HOME% in Windows.. it's a Vim-only variable! So it is accessible from vim command line.
    – roblogic
    Apr 9, 2015 at 0:04
1

For corporative environments usually is set the %HOMEDRIVE and %HOMEPATH% and the GVIM use it (version 8.1 at least) .

option.txt help file :

                            *$HOME-windows*
On MS-Windows, if $HOME is not defined as an environment variable, then
at runtime Vim will set it to the expansion of $HOMEDRIVE$HOMEPATH.
If $HOMEDRIVE is not set then $USERPROFILE is used.

This expanded value is not exported to the environment, this matters when
running an external command: >
    :echo system('set | findstr ^HOME=')
and >
    :echo luaeval('os.getenv("HOME")')
should echo nothing (an empty string) despite exists('$HOME') being true.
When setting $HOME to a non-empty string it will be exported to the
subprocesses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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