I use shorthand to mostly facilitate my handwriting, but also for typing, although the latter carries a lesser benefit with my already rapid typing speed. Nonetheless, some shorthand constructs come at substantial convenience.
The VIM text editor facilitates auto expansion of shorthand by means of abbreviations. I maintain and often modify my abbreviation set in ~/.vim/scripts/abbrev.vim
, of which I demonstrate but a handful of particularly handy constructs:
iab & and
iab 1] first
iab 2] second
iab 3] third
iab 4] fourth
iab 5] fifth
iab af after
iab ag again
iab b but
iab bc because
iab c this
iab cu that
iab d from
iab k can
iab f for
iab fe for example
iab h have
iab j just
iab ja already
iab n not
iab nec necessary
iab q that
iab sm same
iab st such that
iab t the
iab T The
iab yr your
iab w with
iab wrt with respect to
iab wo without
iab wld would
iab wout without
These abbreviations, once enabled and sourced, can sometimes become a hindarance, especially given the individual characters you may want typed verbatim, or when you purposely intend to render the abbreviated form.
On a case-by-case basis, you can prevent expansion via the CTRL-v combination as you type.
Now, to temporarily disable and toggle the abbreviation mode, you must disable the ‘conveniently’ titled paste mode in Vim. I map the toggling of this mode via F10:
" note: expandtab gets disabled when paste mode is off, hence the reset
nmap <F10> :echo "toggling abbreviations (and paste mode)" \|
setlocal paste! \| setlocal expandtab <CR>
However, the title is not without merit. The paste mode exists to avoid a rather nasty side effect.
With the mode disabled (as by default), any abbreviations pasted into the VIM buffer expand. This I find exceptionally frustrating as I paste bits of code or configuration files, not careful to double check the pasted content (who does?). Only later do I detect the discrepancy. To avoid this mess, enable paste mode via the above macro.
Questions, comments? Connect.