Make It Snappy With Vim

Written By
Juliet Kemp
Juliet Kemp
Published: Jul 20, 2010
Updated: Nov 10, 2020
2 minute read
ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More



Vim is still one of the most powerful text
editors out there. One of its more useful features is that it allows you to set up your
own abbreviations and mappings. These can speed up the typing of stock
phrases or do far more complicated things. Enter these in command mode to
try them out, or add them to your ~/.vimrc (without the initial colon) if you want them to stay.

Tip of the Trade: Learn how to set your own abbreviations and mappings in the ever-useful Vim.

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.

Recent Tips
» Unicode Characters in Vim
» SSH From Your Mobile Device
» Recovering Deleted Files With lsof

Read All Tips of the Trade


  • 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.,
    )
  • Reformat the current paragraph according to the current textwidth by
    hitting Ctrl+L:
  • Underline the current line with ,u or double-underline it
    with ,U (this is useful for text note files):
  • 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.
:iab teh the
:iab YDATE =strftime("%a %b %d %T %Y")
:imap gqap
:map  gqap
:imap ,u yypv$r-o
:imap ,U yypv$r=o
:map ,L :%s/(.)n(w)/1 2/

To list all the mappings that have been set, use :map.

Follow ServerWatch on Twitter

Juliet Kemp

Juliet Kemp is a ServerWatch contributor.

ServerWatch Logo

ServerWatch is a top resource on servers. Explore the latest news, reviews and guides for server administrators now.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.