I'm trying to make a protable Neovim so I can use my plug&play IDE from a USB thumbdrive on any offline Windows computer.

I managed to store my plugins and my sysinit.vim onto the USB drive and make Neovim use them.

But while testing I realized that Neovim creates some folders on the host computer.

~\AppData\Local\nvim-data\shada and ~\AppData\Local\nvim-data\swap

Are there more?

In the manual I found that I can change where swap files are stored by setting directory which currently is ~\AppData\Local\nvim-data\swap\\

What about the ShaDa directory?

Is there any way to change stdpath('data')?

I guess there is no way to prevent nvim-qt to create registry entries? (beside making my own build)

  • This question is two years already. Have you found a way to better configure neovim to make it more portable? Also, do you mind share your current portable version?
    – Danielo515
    Aug 24, 2022 at 9:51
  • @Danielo515 not really. but I haven't spent too much time experimenting to be honest. I'm sure there is a way but after a while I just didn't care if there were some unwanted folders.
    – Piglet
    Aug 24, 2022 at 16:00

4 Answers 4


Are there more?

Swap, undo, shada, log... Whatever is found there.

I can change where swap files are stored

IMO, just set noswapfile and forget it.

What about the shada directory?

Read :h shada-n Get used to this: when you need something it's in the help.

I guess there is no way to prevent

Everything is possible. But, at the very least, shada/viminfo is too useful to switch it off.

Is there any way to change stdpath('data')?

From :h standard-path

The $XDG_CONFIG_HOME and $XDG_DATA_HOME environment variables are used if they exist, otherwise default values (listed below) are used

  • Thanks. Yeah the help is really great but I have a few problems to find what I need some times or if I find it it is hard to make sense of it, yet. I read the shada section befor and I didn't realize that changing the shada filename would also change where it is stored. I don't want to turn it off, I just don't want my NVIM to leave files other than those I edit on the computer.
    – Piglet
    May 19, 2020 at 15:59
  • 2
    To help with the first problem (not finding what you are looking for) I recommend reading chapter 2.8 (:h 02.8) including the summary afterwards (:h help-summary). And don't forget about :helpgrep. (If you are already familiar with these things then carry on.)
    – B Layer
    May 19, 2020 at 19:22


The Windows environment variable %APPDATA% contains the path to a folder (%USERPROFILE%\Appdata\Roaming) intended for application specific data in a Windows domain environment (Windows computer network) which are machine independent and should roam with users as they log on to different computers.

Local (%LOCALAPPDATA%) and LocalLow folders are for application data that does not roam with the user. Usually this data is either machine specific or too large to roam.

Some programs e.g. the user specific Chrome installer installs to %AppData%, while the system wide installer installs to %ProgramFiles%.

Neovim/Neovim-qt configuration documentation:

How to change Neovim's LOCALAPPDATA to e.g. LOCALMYAPPDATA

Neovim uses as its data and config folder the %LOCALAPPDATA% environment variable. If you want to set a Neovim specific data folder then inside the binary file C:\Program Files\Neovim\bin\ nvim.exe LOCALAPPDATA can be overwritten to e.g. LOCMYAPPDATA with a binary editor (e.g. https://hexed.it/).

LOCMYAPPDATA can be added to the environment variables as a user or system variable (command prompt: rundll32.exe sysdm.cpl,EditEnvironmentVariables) containing the data path you would like Neovim to use.

Be careful not to add or remove bytes as this can disrupt the precise offsets where headers, sections, metadata and instructions are expected to be found.

C:> set LOCALAPPDATA=Z:\appdata
C:> cd Z:\appdata
The system cannot find the path specified.

C:> nvim.exe --headless +":echo 'Vim datapath:'stdpath('data')|q"
Vim datapath: Z:\appdata\nvim-data

C:> cd /d Z:\appdata\nvim-data\shada
#ifdef MSWIN
static const char *const xdg_defaults_env_vars[] = {
  [kXDGConfigHome] = "LOCALAPPDATA",
  **[kXDGDataHome] = "LOCALAPPDATA",**
  [kXDGCacheHome] = "TEMP",
  [kXDGStateHome] = "LOCALAPPDATA",
  [kXDGRuntimeDir] = NULL,  // Decided by vim_mktempdir().
  [kXDGConfigDirs] = NULL,
  [kXDGDataDirs] = NULL,

Source: https://github.com/neovim/neovim/blob/master/src/nvim/os/stdpaths.c#L24

  • Welcome to Vi and Vim! This answer would benefit greatly from some explanation
    – D. Ben Knoble
    Oct 29, 2022 at 19:12
vim.fn.stdpath = function(name)
    return "custom_path/" .. name

This will move vim.fn.stdpath to the new directory, but using stdpath() in vimscript still doesn't work.

for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = "custom_path/" .. name

or modify vim.env, both vim.fn.stdpath and stdpath() can read correctly path

  • Welcome to Vi and Vim! Are there any side-effects of this monkey patch? It seems like it could interfere with normal operations if not careful
    – D. Ben Knoble
    Jan 18 at 15:55
  • update to modify vim.env, so that stdpath can be read correctly in both Lua and Vimscript. More test is needed to check for any side-effects.
    – fcying
    Jan 19 at 16:27

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.