Sunday, July 24, 2016

Changing the defaults with Vim 8

Vim has always been conservative about the default option values.
Without any .vimrc the default is 'compatible'. That's nice for people
who rely on the old Vi. But how many of these still exist? I expect
nearly all Vim users to want 'nocompatible', thus create a .vimrc ASAP.

What has stopped me from changing this is the unexpected change. Many
users will notice that Vim suddenly behaves differently. Some may be
upset. The release of Vim 8.0 might be the best point in time to do
this. If we do this.

Besides making 'nocompatible' the default, there are a few options that
should probably be on by default. Currently these are in
$VIMRUNTIME/vimrc_example.vim. Most of these only have a visual effect
or slightly change how editing works. You will notice this right away.
The ones that have unexpected effects should be avoided.

If someone wants to start in the old way, the -C flag should be used:
vim -C

If someone wants to start with 'nocompatible', but not all of the new
option values, a .vimrc would be needed to change the settings. This is
the most common and also most tricky part. Assuming that the user will
want most of the new option values, but not all, he should be able to
revert to the old value. For options that is easy. But including the
matchit plugin is not easy to revert.

What we can probably always do:

set backspace=indent,eol,start
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching

" Don't use Ex mode, use Q for formatting
map Q gq

" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
let c_comment_strings=1
endif

if has("autocmd")
" Enable file type detection.
filetype plugin indent on

augroup vimrcEx
au!

" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78

" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif

augroup END
else
set autoindent " always set autoindenting on
endif

if has('langmap') && exists('+langnoremap')
set langnoremap
endif


Probably not:

" these two leave files behind
set backup
set undofile

" may conflict with a user mapping
inoremap <C-U> <C-G>u<C-U>

" hard to revert
if has('syntax') && has('eval')
packadd matchit
endif

Comments?

--
TALL KNIGHT: When you have found the shrubbery, then you must cut down the
mightiest tree in the forest ... with a herring.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: