- Title:
- Set up vi(1) for modern usage
- Authors:
- Paolo Vincenzo Olivo
- Date:
- Topics:
- Lowtech, NetBSD
- Id:
- bdafce
A revised version of my ~/.exrc. Should be self-explanatory.
"""ABBREVATIONS ab #d #define ab #i #include ab #n #ifndef ab #f #ifdef ab #e #endif ab #l #else ab Attr Attributes ab Appl Application ab Vari Variables ab Req Request ab UNI Sapienza Universita' di Roma
"""MACROS (KEYBINDINGS)
""Show help map H :!$PAGER ~/.vi_help^M
""Write out file map Q :wq!^M
""Reload config map R :ex^M
" Go to top of file map gg 1G
" Go to end of file map G GA
""Read and append <cmd> stdout to next line, "" first white space " previous/current file diff map rd +:r!diff -u # %^M " tmux buffer map rb +:r!tmux show-buffer " today date map rt +:r{!}date +\%Y-\%m-\%d^M " XA_CLIPBOARD map rc +:r!xclip -o -sel clip^M " sysinfo map rs +:r!uname -rs^M
""Formatting " indent lines map gi :%!indent -i4 " reformat, wrap text at 72ch map gf :%!fmt -w 72 % " reformat paragraph map gp :?^$?,//!fmt -w 72 " sort lines alphabetically map gs :%!sort -u " process file with hunspell map gh :!hunspell -d en_US % " substitute patterns up to current position map gr :^,.s///g " remove leading tabs map gl :%s/^[ \t]*// " double space, whole file map gd :%!sed G " expand TABS out in buffer map ge 'a!'bexpand "comment lines in buffer map gc :'a,'bs/^/#/ " uncomment lines in buffer map gu :'a,'bs/# *// " remove trailing spaces map gt :%s/ *$//
""Manipulating Buffers " display vi buffers map K :display buffers " cut current line to buffer '1' map C "1Y$dd " paste '1' after current position map V "1PASTE " mark current position as begin of new buffer map # ma " mark current position as end of new buffer map * mb " append new buffer to next line map bv :'a,'b co . " delete marked buffer map be :'a,'b del . " move marked buffer to 'n' line map bm :'a,'b mo . " convert marked buffer to UPPERCASE map bc :'a,'bs/.*/\U&/ " convert marked buffer to LOWERCASE map bl :'a,'bs/.*/\L&/ " trim white space from marked buffer map bt :'a,'bs/[ ^I][ ^I]*$//g " write marked buffer to file map bw :'a;'bw
""TUNABLE OPTIONS " Autoindentation set ai " Discard control characters set bf " Edit command-line history. set cedit=\^[ " Store buffer on tmpfs set dir=/tmp/run/1000 " Encoding set fileencoding=UTF-8 " Case insensitive searches set ignorecase " Hide whitespace and EOL characters set nolist " show line numbers "set nu " Display a row/column ruler set ruler " Additional section boundaries set sections=SeAhBhChDh " Shell env for ! commands set shell=/bin/sh " Show matching brackets set showmatch " Display current editor mode set showmode " Shift width in spaces set sw=4 " TAB width in spaces set tabstop=4 "expand tabs to spaces set et "soft wrap text set leftright " TERM type set term=xterm-256color " Verbose error messages set verbose " 72-N chars wrapmargin set wl=72 "set columns=80 " refresh screen at typed char set redraw