Use Vim. RC to configure Vim

Source: Internet
Author: User

YourVimrcFile is an incredibly powerful, incredibly useful thing. Anything you can do in command-line mode you can do in yourVimrcFile. This makes it possible to make settings (e.g.: Set textwidth = 80) In the command-line mode and then make them permanent in yourVimrcFile 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 onVimrcFile will be in a slightly different place. However, no matter where it actually is you can reference it from within Vim using$ MyvimrcVariable.

On Unix (Linux, OS X, whatever ...)

On these operating systems,VimrcFile 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 yourVimrcFile 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

 

 
: SetSmartindent

 

 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.