1

According to :help starting, we can specify a specific vimrc file using the following command

$ vim -u /path/to/vimrc 

How can I access the path of that vimrc/init.vim file in vim/neovim?

I have tried the following.

expand('%:p')     " returns different path based on opened file
stdpath('config') " returns default vimrc or init.vim path
$MYVIMRC          " it is not set when using -u switch
1
2

Try this:

:echo index(v:argv, '-u') != -1 ? get(v:argv, index(v:argv, '-u') + 1, '') : ''

Require the patch 8.1.2233. See :h v:argv.

At this moment, Neovim 0.4.4 does not have the patch and Neovim 0.5.0 has the patch.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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