WieeRd
WieeRd

Reputation: 1107

Neovim: Relative config file(init.vim) location

I'm moving from vim to neovim, and my problem is that I need to carry it on portable USB sticks. So I need to read config files from relative path. I used $VIM/_vimrc for this purpose on original vim, since $VIM always points to vim files in my USB. But Neovim stores config files in ~/.config on Linux or Appdata on Windows, which both points to local computer's directory I was using. Is their any relative directory Neovim uses to read config files? I don't want to manually source config file every single time...

Upvotes: 5

Views: 17426

Answers (1)

Amadan
Amadan

Reputation: 198526

From :help startup:

    The Nvim config file is named "init.vim", located at:              
            Unix            ~/.config/nvim/init.vim
            Windows         ~/AppData/Local/nvim/init.vim            
    Or if $XDG_CONFIG_HOME is defined:                                   
                            $XDG_CONFIG_HOME/nvim/init.vim     

So you can use $XDG_CONFIG_HOME in a way similar to how you used $VIM before.

Instead of setting $XDG_CONFIG_HOME, you can make a bash alias, or an equivalent wrapper script:

alias vim="vim -u /path/to/vimrc"

Upvotes: 7

Related Questions