I am root on the machine, and have my .vimrc at /root/.vimrc
. Vim ignores this, even though
# echo $HOME
/root
If I do
# vim -u /root/.vimrc some-file-to-edit
vim still ignores it. Setting export MYVIMRC=root/.vimrc
has no effect.
Vim sources my file without problems if I start vim and type :source /root/.vimrc
.
Note VIMINIT
is unset.
What could be preventing vim from sourcing my .vimrc when starting up?
I'm happy to supply any other information that may be helpful, just let me know what.
EDIT 1: excerpt from running vim -V filename
:
...
finished sourcing $VIM/vimrc
chdir(/root)
fchdir() to previous dir
sourcing "$HOME/.vimrc"
Searching for "filetype.vim" in "/root/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,/root/.vim/after"
Searching for "/root/.vim/filetype.vim"
...
The full output is long, so this is just an excerpt to show the line that verifies sourcing of /root/.vimrc
.
EDIT 2: output from running :scriptnames
after vim normally*
1: /usr/share/vim/vimrc
2: /usr/share/vim/vim74/debian.vim
3: /usr/share/vim/vim74/syntax/syntax.vim
4: /usr/share/vim/vim74/syntax/synload.vim
5: /usr/share/vim/vim74/syntax/syncolor.vim
6: /usr/share/vim/vim74/filetype.vim
7: ~/.vimrc
8: /usr/share/vim/vim74/indent.vim
9: /usr/share/vim/vim74/ftplugin.vim
10: /usr/share/vim/vim74/syntax/nosyntax.vim
11: /usr/share/vim/vim74/plugin/getscriptPlugin.vim
12: /usr/share/vim/vim74/plugin/gzip.vim
13: /usr/share/vim/vim74/plugin/matchparen.vim
14: /usr/share/vim/vim74/plugin/netrwPlugin.vim
15: /usr/share/vim/vim74/plugin/rrhelper.vim
16: /usr/share/vim/vim74/plugin/spellfile.vim
17: /usr/share/vim/vim74/plugin/tarPlugin.vim
18: /usr/share/vim/vim74/plugin/tohtml.vim
19: /usr/share/vim/vim74/plugin/vimballPlugin.vim
20: /usr/share/vim/vim74/plugin/zipPlugin.vim
21: /usr/share/vim/vim74/indent/python.vim
22: /usr/share/vim/vim74/ftplugin/python.vim
23: /usr/share/vim/vim74/syntax/python.vim
Again, seems to be sourcing /root/.vimrc
(item 7). Soo... line 8 makes me suspicious: my problem is that the indent settings in my vimrc aren't reflected. Maybe they are being superceeded...
EDIT 3: Placing my file in ~/.vim/after/...
Moving my file to the following locations had no effect on the output of scriptnames
:
~/.vim/after/indent.vim
~/.vim/after/indent.vim/myscript.vim
~/.vim/after/indent/myscript.vim
~/.vim/after/syntax/myscript.vim
~/.vim/after/indent/myscript.vim
~/.vim/after/myscript.vim
And, while moving my to
~/.vim/after/plugin/.vimrc
did change the output of :scriptnames
, causing my file to be sourced after item 20 (see above), it seems my indent settings are still getting overridden (probably by item 21).
Use of the after
directory doesn't work how I imagined (see my list of attempts). Only after/plugins/
seems to be considered.
Is there a way to ensure that the file is sourced after everything?
:scriptnames
when you runvim
normally?~/.vim/after/indent.vim
or~/.vim/after/indent/foo.vim
if you want to override those.~/.vim/after/indent/foo.vim
into consideration. I experimented with different locations under~/.vim/after/...
, but for the most part, files therein are ignored see EDIT 3