Speed-Typing in Vim With Maps and Abbreviations
Better Than a Clipboard
Abbreviations (use iab for abbreviations that work only in insert mode or ab for abbreviations that work in any mode) and mappings (use imap for mappings that work in insert mode, or map for mappings that work in multiple modes) are very similar. Broadly speaking, if you're doing something you'd normally use the command-line mode for, use a mapping. If you want a set of characters to expand into a longer string while you're typing, use an abbreviation.
- The basic 'shorten a stock phrase' type abbreviation:
If you type YDATE, this will output a string like 'Mon May 04 11:01:58 2009'. (You can also use abbreviations to fix common typos, e.g.,
=strftime("%a %b %d %T %Y")
:iab teh the)
- Reformat the current paragraph according to the current textwidth by
gqap :map gqap
- Underline the current line with ,u or double-underline it
with ,U (this is useful for text note files):
yypv$r-o :imap ,U yypv$r=o
- Take out unwanted newlines: Turns every paragraph into a single line:
This is helpful when you're editing config files that need not have line breaks (e.g. ~/.ssh/authorized_keys2), but you have your textwidth set for normal reading of textfiles.
:map ,L :%s/(.)n(w)/1 2/
To list all the mappings that have been set, use :map.
Article courtesy of Serverwatch; Follow ServerWatch on Twitter
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.
- 1Linux Top 3: GNOME 3.12 and New Betas for Ubuntu 14.04 and OpenMandriva Lx 2014.0
- 2Linux Top 3: Linus Lashes out, Linux 3.14 Gets PIE and Ubuntu One is Done.
- 3Linux Top 3: Ubuntu 14.04, Debian Gives Squeeze More Life and Red Hat Goes Atomic
- 4Linux Top 3: Linux 3.11, Kubuntu Goes Commercial
- 5Linux Top 3: RHEL 6.5, Debian 7.2 and EOL for Linux 3.0.x