Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Location of my .vimrc file in Ubuntu 14.04

Tags:

linux

vim

ubuntu

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.

like image 583
John Doe Avatar asked Jul 09 '14 13:07

John Doe


People also ask

Where is .vimrc file located in Ubuntu?

Vim Configuration Files: Vim can be configured system wide (globally) via the /etc/vim/vimrc. local file on Ubuntu/Debian based operating systems. On CentOS 7 and RHEL 7, the system wide configuration file for Vim is in /etc/vimrc.

Where can I find .vimrc file?

The global or system-wide vim configuration file is generally located under the /etc/vim/vimrc . This configuration file is applied to all users and when Vim is started this configuration file is read and Vim is configured according to this file contents.

How do I create a .vimrc file in Ubuntu?

vimrc using vim. In vim, add the commands that you know you want to put in, then type :wq to save the file. Now open vim again. Once in vim you can just type: :scriptnames to print a list of scripts that have been sourced.


2 Answers

: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.

like image 197
Ingo Karkat Avatar answered Sep 30 '22 13:09

Ingo Karkat


I would exit vim, and

echo 'set statusline+=%F' > $HOME/.vimrc
like image 22
Elliott Frisch Avatar answered Sep 30 '22 15:09

Elliott Frisch