Reputation: 2924
I am working on a newly installed Ubuntu system. I created a my vimrc by typing vim and the then I did :e $MYVIMRC. I landed up in an empty file, I wrote something this
" Add full file path to your existing statusline
set statusline+=%F
But even after that if I am opening vimrc again by using :e $MYVIMRC its not showing up anything on top as file location path.
Upvotes: 7
Views: 13049
Reputation: 172510
:help $MYVIMRC
clearly states:
The $MYVIMRC environment variable is set to the file that was first found, unless $MYVIMRC was already set and when using VIMINIT.
So you can use that to open an existing Vim configuration, but not to create it. If you watch closely, you'll see that
:e $MYVIMRC
:w
will respond with
"$MYVIMRC" [New File]
So, you've created a file named $MYVIMRC
in the current directory (as the variable hasn't been set).
To create an empty .vimrc
, just use
:e $HOME/.vimrc
Since this is a one-time action, all this worrying about the right approach isn't really helpful, anyway.
Upvotes: 11
Reputation: 201409
I would exit vim, and
echo 'set statusline+=%F' > $HOME/.vimrc
Upvotes: 1