Vim Tips Wiki

Tonymec/Sandbox/Example vimrc (Comments)

< User:Tonymec | Sandbox

Revision as of 17:19, August 8, 2009 by Tonymec (Talk | contribs)

1,616pages on
this wiki
As long as this page is a subpage of my Sandbox, it means I'm not satisfied with its text and don't yet want to release it to the public. Maybe you came here through a wrong URI? Read on at your own risk, and certainly don't be offended; the following is only a very rough draft and I'll have to rework it several times before I ever show it to the general Vim Tips wiki readership.


Hm. I don't know who are those "ops and regulars of the #vim community" (on Freenode), but I'm not one of them — rather, I'm one of the regulars of the Vim users groups (currently on Google Groups, previously at, founded by Bram Moolenar himself, and IMHO much more central to "the Vim community" in general if there is one (without qualification).

There are many things in the above vimrc which I would certainly never recommend; I might even warn against them. Let's go over the above statements line by line:

set nocompatible
filetype indent plugin on
syntax on

I agree with these ones (except maybe having filetype-indent on, but that's my choice), however none of these is any reason for a slur against the vimrc_example.vim — it also has them. For portability, I'd recommend wrapping the latter two commands in an appropriate :if clause, maybe if has('autocmd'), to avoid errors if someday that vimrc is found by a Vim executable lacking the compiled-in features they require.

set hidden

I strongly disagree with the notion that "any sane Vim setup should have it". On the contrary, IMHO this option should not be set by users who haven't studied all its ins and outs and aren't sure of what it implies. If you set 'hidden', you won't get any warning that you are about to "abandon" a modified file. Instead, Vim will "hide" it, with no visible sign that you have unsaved files in Vim memory. This could lead to severe dataloss if, let's say, there is a power letdown while you have many such unsaved files hidden by Vim. I personally prefer

	set autowriteall

instead (meaning, "save a modified file when I leave it, if at all possible"), but that may be due to the behaviour of the editor which was my favourite on Dos 2 and 3, before I even heard of Windows. YMMV.

set autoindent

I agree that this one is useful (I use it), but maybe not to the point of waxing lyrical and saying that "any sane Vim setup should have it". Some users may want it, other not, and IMHO there's nothing "insane" in either preference.

set nostartofline

This makes some linewise commands such as   gg   :25   G   keep the cursor in the same column (or try to) rather than go to the first non-blank. I prefer to leave this option at its "on" default.

set wildmenu

Here I agree 100%. IMHO this is one extremely useful setting which was "left out" by default, even after sourcing the vimrc_example.vim

set showcmd
set hlsearch

I agree that these are useful; the vimrc_example.vim sets them too.

set ignorecase
set smartcase

I like these ones too, and I agree that they are largely a matter of personal choice.

set backspace=indent,eol,start
set ruler

These are already set in the vimrc_example.vim

set laststatus=2

I agree.

set confirm

...but here I don't. You also have to know what you want: 'hidden' or 'confirm' — or 'autowriteall' which is what I use? IMHO only one (at most) of these options should be on — or did I miss something?

I JUST found this option today and set it immediately. It's exactly what I've been looking for. 'hidden' is too risky for my usage, and I would HATE autowriteall because I only want to save the file when I'm good and ready. I agree that only one of these three options is really needed at any given time, which may be why none of them are on by default. On Windows at least, it actually works best IMO with set guioptions+=c --Fritzophrenic 20:37, 6 August 2009 (UTC)
'autowriteall' does nothing until or unless you |abandon| a buffer. But it's not for everybody. Let's check :help 'go-c' now... ah yes, avoid popup dialogs for simple choices: that one I didn't know yet, but I'm gonna try it. --Tonymec 17:19, 8 August 2009 (UTC)
" set the Vim alarm to neither flash nor beep
set visualbell t_vb=

I prefer the opposite, as follows:

	" set the Vim alarm to both flash and beep
	set visualbell
	if 1	" arithmetic evaluation compiled-in
		let &t_vb = "\x07" . &t_vb
		" 0x07 is the BEL character. On most screens, "displaying" it sounds an audible bell.
	if has('autocmd') && has('gui')
		" we must also override the new setting in the builtin_gui termcap
		au GUIEnter * let &t_vb = "\x07\e|50f"
		" here, 50 (after Escape-Bar and followed by f)is the flash time in milliseconds
set mouse=a

The vimrc_example.vim also has this, except that it wraps it within if has('mouse') to avoid errors when run on a Vim version built with no mouse support.

set cmdheight=2

I agree, for the same reasons. Still a matter of personal preference, of course.

set number

I don't. For me, setting 'number' is the exception rather than the rule. I may write

	<!-- vim: set nu nuw=1 :-->

in an HTML page, or a similar modeline for another language, to have numbers for this file only (in a column as narrow as possible for the number of lines in the file)

Around Wikia's network

Random Wiki