In order to ensure that behaviour is not affected by my personal config, I want to start Vim in a way that ignores all my user-installed config files, as if Vim had just been freshly installed for the first time and the user had run it immediately.
This is addressed in the FAQ which suggests that the answer is to start Vim with the following command:
vim -u NONE -U NONE -N -i NONE
This gets most of the way there, but the runtimepath
option still contains ~/.vim
and, notably, ~/.vim/after
, (so e.g. if I subsequently turn on file type detection and change filetype, code in ~/.vim/after/syntax/the_relevant_filetype.vim
will be executed).
I can workaround this specific problem by invoking the following commands on startup*:
:set runtimepath-=~/.vim
:set runtimepath-=~/.vim/after
...but I'm not sure if:
- This is a robust solution: Are those the only paths that can cause user-configuration to take effect? Is there anything else I haven't thought of?
- There is a better way of achieving the desired result.
* By using --cmd
or -u vimrc
shell arguments, or simply by typing them manually.
EDIT: Here's one specific example of the sort of problem I'm trying to fix. (Although I'd like the solution to fix any other possible issues I might not yet have encounted.):
Create a file ~/.vim/after/ftplugin/c.vim, containing the content:
noremap i :echom "This is not default behaviour"<CR>
Now we have some user-installed configuration that we want to ignore. Let's test the solution suggested by the FAQ.
Run Vim with the command:
vim -u NONE -U NONE -N -i NONE
Enter the commands:
:filetype plugin on :set ft=c i
Desired behaviour: Vim should enter Insert mode. This is what it would do if no user configuration existed.
Observed behaviour: Vim prints out "This is not default behaviour"
HOME=/dev/null vim -u NONE
?:cd ~
, but also the default location of theviminfo
file is in $HOME, which can cause E138. I guess creating a new, empty directory and using that for $HOME might be the best solution.-u NONE
?/tmp
might be better, it was my first thought, but then I chose /dev/null as a black hole. ... Or something likeHOME=$(mktemp -d) vim ...
.-u NONE
? Depends on what behaviour you need, I suppose.