1

I wanted to upload my .vimrc file to GitHub and while doing that, I think I broke something. After that process, when I type vim ~/.vimrc on my terminal, the only thing I see is runtime vimrc instead of my .vimrc.

How can I see my actual configuration?

1 Answer 1

2

$HOME/.vimrc has been the historical location for the user's vimrc for a very long time. We also had a separate directory for our plugins, colorschemes, etc.: $HOME/.vim. That's two "objects" to keep tabs on:

$HOME/.vimrc
$HOME/.vim

Not ideal.

Since 7.4, we have the possibility to put our vimrc inside our $HOME/.vim directory without having to tweak anything:

$HOME/.vimrc        " identical files
$HOME/.vim/vimrc    " different name and location

This is pretty cool because it gives us a fully contained setup in:

$HOME/.vim

that we can easily move around between machines, back up, or put under version control.

But when 7.4 was released, almost exactly 10 years ago, not all vims would be automatically updated and it usually took some time for distros to pick up, etc. This meant that it was far from uncommon for someone to want to use their setup with 7.4 on one machine and 7.3 or 7.2 on another. Of course, older Vims didn't know about that new scheme and only cared about:

$HOME/.vimrc

which made the new scheme not backward compatible. Bummer.

The solution was pretty easy, though. On machines with older Vims, all you had to do was to have this line and only this line in your $HOME/.vimrc:

runtime vimrc

which is a convenient way to tell Vim to source the first file called vimrc it can find in the directories listed in the :help 'runtimepath' option:

$HOME/.vim/vimrc
$VIM/vimfiles/vimrc
$VIMRUNTIME/vimrc
$VIM/vimfiles/after/vimrc
$HOME/.vim/after/vimrc

So you had your real config with all the options and mappings and stuff living at:

$HOME/.vim/vimrc

which Vims >= 7.4 could pick up without handholding, and, on machines with a lesser Vim, a minimal "stub" living at the historical:

$HOME/.vimrc

that would point to the "real" vimrc.

But that was 10 years ago. Vim is now at 9.0 and it is very uncommon (but not impossible so YMMV) to encounter a 7.3 or 7.2 in the wild, so this scheme is not as generally useful as it used to be.

Now, back to your situation…

Check if you have a vimrc (withot the .) with the expected content in your $HOME/.vim:

$ cat ~/.vim/vimrc

If no, then you are in trouble and you will need to provide us more information about what you did and where. Don't delete anything until we see more clearly through that mess.

If yes, it means that your $HOME/.vimrc is effectively used to bootstrap your config, which is almost certainly pointless. If you are not using any version of Vim < 7.4 (check $ vim --version), then you can safely get rid of that file. Once you are done, $HOME/.vim/vimrc will become your one and only vimrc, which you can edit in Vim with :edit $MYVIMRC.

In any case, whatever resource you followed to end up in this situation is either incomplete or severely outdated. FWIW, I used to suggest that setup in older versions of my Idiomatic vimrc guide but only

If you use both 7.4 and an older version, or only an older version, […]

If that doesn't apply to you, then that scheme is useless.

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.