Happiness is a good .vimrc file


When VIM starts up, it reads your personal settings before it does anything interesting.

To create personal settings, you can edit a file named .vimrc in your home directory.

The instructions up until now give you enough information that you should be able to edit your .vimrc file and add all the commands listed below.

The idea is to enter the commands in the leftmost column of the table.

You will have to type them, and correct any spelling errors.

Once the file has been created, you will save and exit and the next you start VIM it will have your settings.

You can edit this file at any time.

There is very fine magic in VIM. However, it often comes without the magic turned on. Command line completion, color syntax highlighting, the file explorer, and many other features are "missing" unless you turn them on in ~/.vimrc.

There is a very nice guide to the various settings in vim, and even an interactive display so that you can turn them on and off. This is not very well-known, I suspect, because I only learned it this year. I wish I had known when I was first starting.


:options
:browse options
:browse set


In this window, you can browse through all the available options, and can even set them. You can read the short help messages associated with each, or you can hit the enter button on any short help to see the longer help text. If you press the enter key on an option, it will toggle that option or set a new value.

Each of these commands has a shortcut, but you can learn those later.

Try entering just the first five commands (one-per-line), save the file, and then edit it again to add the other commands.

You will find that the second session will have color syntax highlighting, and will give you more hints and help as you work.


Command in .vimrcMeaning
syntax enableturn on all the magic, including Explorer and syntax highlighting
set showmodeShow me when I'm in insert/overtype mode
set showcmdWhen a command is in progress, show it in the status bar
set wildmenumagic for completion at the : command line.
set ruler<turn on the "ruler" (status info) at the bottom of the screen.
runtime ftplugin/man.vimTurn on man pages (type :Man )
set autoindentindent in a smart way, instead of returning to the left margin all the time
set expandtabexpand tabs to spaces
set nowrapDon't wrap text (makes windows ugly)
set hlsearchHighlight all matches in text when you search
set showmatchShow matches for braces, parens, etc.
set ignorecasedo case-insensitive searching
set smartcaseWhen a search phrase has uppercase, don't be case insensitive
set path=.,..,/usr/include/**,/usr/share/**Tell the editor where to search for files
set spelllang=en_uswhen I want spell-checking, I want it to be english

No comments:

Post a Comment