Saturday, April 11, 2009

Abbreviations in Vim

There are a few bits of text that are common to almost every file I edit with Vim. One of them is, of course, my name. The others are my e-mail address, and the date.

Vim allows you to define simple text abbreviations to make entering such strings super-easy. Here's a snip of my .vimrc.

" Some handy abbreviations.
" Insert date.
iab xdate =strftime("%Y/%m/%d %H:%M:%S")

" What's my name?
iab xname Mohit Muthanna Cheppudira

" My personal sig.
iab xsigp Mohit Muthanna Cheppudira

" My work sig.
iab xsigw Mohit Muthanna Cheppudira

With the above in my Vim configuration, the text xdate gets auto-replaced to today's date.


No comments:

Post a Comment