:set autoindent
:set shiftwidth=4
:set tabstop=4
:set showmatch
:set showmode

set ai
set cedit=\^[
"set dir=/tmp/run/1000
set fileencoding=UTF-8
set ic scs
set nolist
set nu
set report=0
set ruler
"additional section boundaries
set sections=SeAhBhChDh
"shell env for ! commands
set shell=/bin/sh
set showmatch
set showmode
set sw=2 ts=2 et
"soft wrap text
set leftright
"set term=xterm-256color
set verbose
"72-N chars wrapmargin
set wl=72
"set columns=80
set lazyredraw

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