Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

ViM: viminfo

📅 2010-Nov-04 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ vim, viminfo ⬩ 📚 Archive

ViM uses the viminfo file as a memory dump to remember information from the last session. On Windows, this file is named _viminfo and stored in the directory %HOMEDRIVE%/%HOMEPATH.

For example, on a home computer %HOMEDRIVE% might be C: and %HOMEPATH% might be \Users\Joe. Thus, ViM will use C:\Users\Joe\_viminfo

For computers which are connected to a work domain, the %HOMEDRIVE% and %HOMEPATH% are typically set to shared folders on the network. These folders might sometimes be down or slow, causing error messages related to viminfo. Therefore, the default viminfo location on Windows is not appropriate if the computer is on a work domain. A good place for it would be the %LOCALAPPDATA% directory.

To indicate a different viminfo directory to ViM, add this to the vimrc file:

set viminfo+=n$LOCALAPPDATA/_viminfo

The viminfo option is a comma-separated list of parameters. Each parameter is specified by a single character, followed by a number or string that is the value of that parameter. The viminfo file parameter is specified by the letter n, followed by the string that is the path where _viminfo should be stored. Enclosing the path in double quotes does not work! :x

Note the += operator used to set the viminfo option. The viminfo option already has a bunch of parameters that are specified by default. Thus, we append the viminfo file path parameter to this by using the += operator.