Command
Description
Nocompatible
Set nocp
This changes the values of a LOT of options,
Enabling features which are not Vi compatible
But really really nice.
Digraph
Set digraph
Enables input of special characters by a combination of two characters.
Example: Type ‘a’, erase it by typing CTRL-H –
and then type ‘:’ – this results in the umlaut: ä
So Vim remembers the character you have erased and combines it
with the character you have typed “over” the previos one.
Esckeys
Set ek
Enables recognition of arrow key codes which start off with an ESC.
This would normally end your current mode (insert/append/open mode)
and return you command mode (aka normal mode), and the rest of the
code would trigger commands. bah! Although I dont use the arrow
keys often, I sometimes want to use them with replace mode and
Virtual editing And I don’t want to be *that*
Compatible to vanilla vi, anyway. .
Hidden
Set hid
Allows hiding buffers even though they contain modifications
which have not yet been written back to the associated file.
Ruler
Set ru
Shows the “ruler” for the cursor, ie its current position
with line+column and the percentage within the buffer.
This saves me typing CTRL-G (or better “g CTRL-G”) –
And many users like this feature, too.
And it is nice when showing Vim.
Showcmd
Set sc
Show the input of an *incomplete* command.
So while you are typing the command “y23dd
You will see “y23dd before you type
The last ‘d’ which completes the command.
Makes learning Vi much simpler as you get
Some feedback to what you have already typed.
Visualbell
Set vb
Chose “visual bell” effect rather than “beeping”.
Wildmenu
Set wmnu
Make use of the “status line” to show possible completions of
command line commands, file names, and more. Allows to cycle
Forward and backward throught the list.
This is called the “wild menu”.
Noerrorbells
Set noeb
Turn off the bell. You do know the “beep”
You get when you type ESC in normal mode?
Be nice to your co-workers – turn it off! 😉
Noexpandtab
Set noet
When inserting text do not expand TABs to spaces.
While I try to avoid all control characters in text
I can make good use of TABs when typing a table.
And I know I can always make Vim expand the TABs later
(using the “:retab” command). Your mileage may vary..
Nostartofline
Set nosol
Prevent the cursor from changing the current column
When jumping to other lines within the window.
(And if you like that then you’ll “virtual editing” with Vim-6! 🙂
Autoindent
Set ai
Automatic indentation. This automatically inserts the
indentation from the current line when you start a new line;
in insert mode you would start a new line by ending the current
one by inserting CTRL-J or CTRL-M – and in command mode you’d
“open” a new line with either ‘o’ or ‘O’ for below or above the
Current line, respectively.
By the way, “autoindent” is actually a feature of vanilla vi.
Backspace
Set bs=2
Backspace with this value allows to use the backspace character
(aka CTRL-H or “<-") to use for moving the cursor over automatically inserted indentation and over the start/end of line.
Formatoptions
Set fo=cqrt
The formatoptions affect the built-in “text formatting” command.
The default value omits the “flag” ‘r’ which makes Vim insert a
“comment leader” of the line when starting a new one.
This allows to add text to a comment and still be
Within the comment after you start a new line.
It also allows to break the line within a comment
Without breaking the comment.
Laststatus
Set ls=2
This makes Vim show a status line even when only one window is shown.
Who said a status line is only useful to separate multiple windows?
Shortmess
Set shm=at
This shortens about every message to a minimum and
thus avoids scrolling within the output of messages
and the “press a key” prompt that goes with these.
Textwidth
Set tw=72
This explicitly sets the width of text to 72 characters.
After each completion of a word in insert mode
Vim checks whether its end is past this width;
if so then it will break the word onto the next line.
Note that Vim will remove trailing spaces when applying
the word wrap – a feature which many editors are missing
(and which will leave trailing spaces, of course).
NOTE: The word wrap applies only when the *completed* word
goes over the line; when you insert a word before that
which moves other words over the line then Vim will *not*
break the words at the end of the line onto the next line!
Programmers certainly don’t want that. It’s a feature!!
Whichwrap
Set ww=<,>,h,l
There are several commands which move the cursor within the line.
When you get to the start/end of a line then these commands will
fail as you cannot go on. However, many users expect the cursor
to be moved onto the previous/next line. Vim allows you to chose
which commands will “wrap” the cursor around the line borders.
Here I allow the cursor left/right keys
As well as the ‘h’ and ‘l’ command to do that.
Comments
Set com=b:#,:%,n:>
Vim can reformat text and preserve comments (commented lines)
even when several kinds of comment indentation “nest” within.
(This is very useful for reformatting quoted text in Email and News.)
But you need to tell Vim how the comments look like.
Usually a comment starts off with some string,
Which may require a following blank.
Comments may also span over lines by starting off with some string,
skipping some middle part, and then end with another string
.
I simply removed the “/* foo */” commenting from the
default value and added that ‘)’ can also be “nested comments”.
List listchars
Set list
Set lcs=tab:»·
Set lcs+=trail:·
This option is cool! Or let’s say that
“other editors don’t have that at all.”
These characters are called “list characters”
As they are related to the list option
Of vanilla vi:
This will show the end-of-lines by adding a
‘$’ sign after the last character of each line,
And by replacing all TABs by ‘^I’.
However, it is much nicer to still have TABs
Shown in expanded form.
Vim takes it one step further by
Also making trailing spaces visible.
Being able to see EOLs, TABs, and trailing space
Has become an absolute MUST with every editor.
Viminfo
Set vi=%,’50
Set vi+=\”100,:100
Set vi+=n~/.viminfo
The idea of “viminfo” is to save info from one editing session
for the next by saving the data in an “viminfo file”.
So next time I satrt up Vim I can use the search patterns from
the search history and the commands from the command line again.
I can also load files again with a simple “:b bufname”.
And Vim also remember where the cursor was in the files I edited.
See “:help viminfo” for more info on Vim’s “viminfo”. :-}
NOTES:
I have grouped the options such that the Boolean ones
(read: on/off true/false) come first, then those with
a short amount of “flags”, and after that the ones
With a very long value.
With all “:set” command you can leave out the colon
before the “set” when you put them into the setup file.
And you can set many options in one command line.
The values of the options “comments”, “listchars”, and
“viminfo” can become quite long, so I have broken them up
In the table into several “set” statements, using
:set += to add further value to the current one.
Getting help on options:
You can get help about options and their values with
:help option.
You need not enter the full option name –
Many option names have abbreviations, eg
“ai” abbreviates “autoindent” – and
‘tabstop’ can be abbreviated with “ts”.
And it suffices to enter “h” instead of “:help”.
Isn’t “:h ai” much shorter than “:help autoindent”?
Caveat: :h ts gives you the help on
The command :ts;
but when you want info on the *option* “ts” the you
should add at least one “tick” before or after it,