YourVimrc
File is an incredibly powerful, incredibly useful thing. Anything you can do in command-line mode you can do in yourVimrc
File. This makes it possible to make settings (e.g.: Set textwidth = 80
) In the command-line mode and then make them permanent in yourVimrc
File by just doing the exact same thing but in a file instead of in the running Vim session.
Where it is
Depending on what operating system you're re running onVimrc
File will be in a slightly different place. However, no matter where it actually is you can reference it from within Vim using$ Myvimrc
Variable.
On Unix (Linux, OS X, whatever ...)
On these operating systems,Vimrc
File defaults to being in your home directory~ /. Vimrc
. If it's not there then just create it by editing it and saving it.
On Microsoft Windows
On all of the MS windows variants you'll also find this in your home directory but most people don't know where that is ;). i'm not going to try and tell you where it is, specifically and leave that up towikipedia's home directory page. in general however it is one directory up from the directory that contains your "events" (e.g. "My Documents" in Windows XP ). the major difference is that it'sNamed slightly differentlyThan it is in UNIX: It's named _ vimrc.
What's it?
everything . OK, that's not strictly true but at this stage in the game it's more than sufficient to look at it that way. in practice you'll find that plugins and your other types Of file type specificconfiguration will make use of Vim's extensive capabilities in its runtime structure, outside of the vimrc
file but that sort of thing comes... Later.
Generally you shoshould think of yourVimrc
File as holding your own personal option settings, mappings, functions, commands and whatever else you need to customize Vim for your personal use.
Short example:
Make vi-Vim never use tabs (converting spaces to tabs, bad !), Makes the tab key = 4 spaces, and automatically indent code after curly brace Blocks
Set smartindentset tabstop = 4 set shiftwidth = 4 set expandtab
The help files take a bit of time to get used to but the more you read the better Vim gets:
: Help smartindent
Even better, you can embed these settings in your source for Portability:
: Help auto-setting
To see your current settings:
: Set all
Use the smartindent format
: Set
Smartindent