How do you set up a .vimrc file on Ubuntu?
This is not helping: http://vim.wikia.com/wiki/Open_vimrc_file
I know the stuff I want to put in it, just don't know how.
All you have to do is to create a . vimrc file in the HOME directory of the user than you want to configure Vim for and add the required Vim configuration options there. For simplicity, I will refer to both system wide Vim configuration file and user specific Vim configuration file as vimrc file.
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.
Sourcing it is the same as typing each command in order. You source with the command :source (usually shortened to :so ). The only file sourced by default is the . vimrc ( _vimrc on windows) so that's a place you can keep all the commands you use to set up Vim every time.
Where:
On UN*X systems your .vimrc belongs in your home directory. At a terminal, type:
cd $HOME vim .vimrc
This will change to your home directory and open .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. The full path to your .vimrc should be in that list. As an additional check that your commands have been executed, you can:
echo "MY VIMRC LOADED"
command to the .vimrc, and when you run vim again, you should see MY VIMRC LOADED printed in the terminal. Remove the echo
command once you've verified that your.vimrc is loading. echo
once vim is loaded. In the .vimrc add a line like let myvar="MY VIMRC LOADED"
. Then once you've opened vim type echo myvar
in the command line. You should see your message.The Format:
The format of your .vimrc is that it contains Ex commands: anything that you might type in the vim command-line following :
, but in your .vimrc, leave off the :
.
You've mentioned :set ruler
: a .vimrc with only this command looks like:
set ruler
Search for example vimrc and look over the results. This link is a good starting point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With