[Tutor] [off-topic] vi/vim editor settings (was: Pep 8, about indentation)
cs at zip.com.au
Sat Aug 8 09:14:22 CEST 2015
On 07Aug2015 21:50, Alex Kleider <akleider at sonic.net> wrote:
>On 2015-08-07 20:56, Cameron Simpson wrote:
>> autoindent: start the next line's text on the same indent as this one
>> expandtab: write spaces instead of a TAB character
>> shiftwidth: how far the < and > shift-text operations move
>> tabstop: the multiple used to tabstops - every 4 columns for me
>Here is what I've got in my ~/.vimrc file:
>>Happy to post my other settings should anyone care.
>... and yes, I for one certainly do "care."
>I'd very much like to see your other settings.
Ok. Here are my other vi settings which I think useful (it seems I have plenty
which aren't). Vim specific settings follow after that.
Automatically save the file when switching to another. Saves tedious :w and
also worrying about whether I should, not to mention all those "file
Saves fiddling with shift keys.
Searches do not resume from the top of the file if nothing found below the
current position. I used to have this on, but now consider this more
I forget, probably dates from editing over a 300baud modem.
Threshold for reporting changed lines.
Highlight matching open/close bracket. Handy for nested stuff. And C code.
Longer warnings and other messages.
Trust me, I'm a doctor. (I'm not.)
map! \c cs at zip.com.au
map! \C Cameron Simpson <\c>
Insert mode macros to recite my email, short and long.
I've got matching ones for my partner's email, very often CCed or
Suspend the editor, just as with ^Z in the shell.
Redraw the screen then resume inserting.
Emacs mode motion: start of line, left, end of line, right, resume insert
map # :n #
Edit the previous file. Very very handy.
map g Gz.
Go to line and position it in the centre of the screen.
map q ZZ
Save and quit.
map t :ta
Commence "go to tag".
map Y y$
Yank to end of line.
map 1G}-:.r!exec </dev/tty 2>/dev/tty; readline -B 'Attach: '
My uber-convenient "attach file" macro. In mutt (my mailer) an "Attach:"
header gets turned into a real attachment. So this macro runs a bit of
shell to issue the prompt "Attach: " and accept the filename you typ, _with
filename completion!_. And inserts that as an Attach: header. When I leave
the editor, mutt adds the file to the attachments for this message.
My terminals have a dark background.
I like my syntax highlighting.
set wildmenu wildmode=list:longest
Make vim's filename completion act more like zsh's, which I find far more
ergonomic than bash's. Essentially: complete as much as you can and
_immediately_ show me the remainder without an extra TAB keystroke.
Case insensitive searches unless there is an uppercase letter in the search
Show the first match in the file as you type the search regexp.
I prefer to overwrite the original file instead of making a new one and
cutting it in with rename(). The former edits the file I intended to edit.
The latter breaks hardlinks and has to do silly hoop jumping with symlinks.
Gah! Do what I say, not what you think I want!
Vim's fetish for .swp files drives me mad, especially if one loses remote
sessions regularly or terminal emulators die or one coworks with others in
the same directories or simply closes one's laptop one a whim or moves
around. I save files very regularly anyway, so I pretty much never lose a
Trust the filesystem, the filesystem is your friend. Once I've handed the
file to the OS (i.e. written it) I do not want to shout at the OS: not get
that onto the disc, now! Especially when fsync() means sync(0 on many
filesystems i.e. write _all_ pending disc I/O before returning, often with
a huge and visible hit to the system behaviour.
Like you, keep some screen context.
Yes, my terminal have lots of colours.
Better display instead of lower bandwidth display.
Additional words to augument the spelling table.
Spell checking off by default.
let g:loaded_netrw = 1
I forget. Anyone?
map <F3> :set hlsearch! nospell! <CR>
F3 turns off highlighting.
and when composing email I use:
This supports writing format=flowed email text. See ":help fo-table".
Cameron Simpson <cs at zip.com.au>
Philosophy is questions that may never be answered. Religion is answers that
may never be questioned. - anonymous
More information about the Tutor