Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set up .vimrc

Tags:

vim

ubuntu

How do you set up a .vimrc file on Ubuntu?

This is not helping: http://vim.wikia.com/wiki/Open_vimrc_file

  1. Where do you create it?
  2. Whats the format inside?

I know the stuff I want to put in it, just don't know how.

like image 867
Eric Sauer Avatar asked Jul 19 '12 18:07

Eric Sauer


People also ask

Where can I create a .vimrc file?

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.

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.

How do I create a .vimrc file in Windows?

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.


1 Answers

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:

  • add an 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.
  • set a variable in your .vimrc that you can 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.

like image 195
pb2q Avatar answered Oct 07 '22 14:10

pb2q