Monday, July 25, 2016

Re: Changing the defaults with Vim 8

On 24.07.16 15:02, Bram Moolenaar wrote:
> 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.

That "not easy to revert" initially sounds decidedly scary to one who
has never heard of matchit. ... Ah, it merely adds matching HTML tags to
the sensibilities of %, apparently? (Had to read ":h matchit" several
times to distil that nub. I.e. it doesn't "makes the "%" command jump",
but rather _adds_ targets to the preexisting functionalityi, AIUI.)

What about putting new defaults into a default .vimrc, installed as part
of the Vim package, iff no .vimrc preexists at install time? Then any
hirsute gremlins with bad breath ought not be irrevertible, I figure.

> 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

Wouldn't change anything here, except the last one, and that's easily
negated with a .vimrc setting.

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

The additional formatting mapping would do no harm.
(The only related thing used here is: noremap ^W gq}
but that'd doubtless not suit many others at all, if any.)

> " In many terminal emulators the mouse works just fine, thus enable it.
> if has('mouse')
> set mouse=a
> endif

Copying/pasting to/from terminal windows with Vim has worked fine for
many years without that, i.e. "mouse=". The only doubt I have is that
"mouse=a" might enable associated defaults, leading to the need to
fiddle them or restore "mouse=", neither of which is a biggie.

> if &t_Co > 2 || has("gui_running")
> syntax on
> set hlsearch
> let c_comment_strings=1
> endif

Well, that horror is quickly fixed with a "syntax off", so it's not a
problem. (But the negative vote on this one seems to be climbing.)

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

The "indent" could perhaps be an unwelcome surprise? Didn't know about
"filetype indent" until now. Haven't yet found any mention of
pre-existing indent files, or link thereto, at *:filetype-indent-on*.
Will also have to do some digging for indent file syntax, examples, etc.

> 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

Having a bunch of my own autocommands for textwidth, the above stuff
would only be welcome if included in a default .vimrc which would not
displace or interact with the user's, if extant. During a multi-file
edit, :bu already brings me back to the previous line, and complains if
it's gone, so I don't understand what the above line restoration stuff
adds? (If it adds persistence, then that'd be horrible.)

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

Seems good - though I haven't used langmap, as a switch to Danish needs
extra characters, not substitutions, so I use mappings for åæø.
For the very occasional bit of German, äöüß, I merely resort to ^k.

>
> Probably not:
>
> " these two leave files behind
> set backup
> set undofile

I've never used them, and would object to the clutter.

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

Good guess. :-) I have:

" ^U Uppercase current word, _in_insert_mode!:
inoremap <C-U> <Esc>gUiw`]a

There's some chance of remembering that; ^F, no chance.

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

"hard to revert" == "impermissible default", _if_ it could be a problem.
But if % bounces between HTML tags, and that isn't desired, then don't
press %, or get off the HTML tag, I figure.

I second Christian's nrformats suggestion, as far as excluding octal by
default, but would go further with nrformats=hex,alpha as a default.
Having those in addition to the implicit decimal default is useful, and
I can't quite see where it could be harmful.

Many thanks for the world's best editor, which exceeds my needs to the
point I've had to become choosy about features I'll stop to learn.
(Wouldn't give up the several kinds of folding for anything, though.)

Erik

--
--
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: