next up previous contents
Next: Learning more about Vim Up: The Woodnotes Guide to Previous: Spell Checking   Contents

Macros

The easiest way to deal with repetitive text is to assign it to a keyboard macro using the imap command. If you enter :imap „br Best regards,, the effect will be to map the expression ``Best regards,'' to the key combinaton „br. Try a couple of these so you are familiar with the possibilities. Choose something exotic like the double-comma combination I use here to avoid stumbling on those keys in regular text. Note that once you've defined a macro, the cursor will change when typing if you begin to enter those first keys while it decides whether or not what you're typing triggers a macro. When you quit Vim, the macros will vanish.

For a longer term solution, put the macros in a file and source it, as follows. Let's say you create a file called ``keystrokes.vim'' Stuff it with lines like imap „br Best regards,. Then, from Vim, issue :source keystrokes.vim and the new functionality will be imported. The .vimrc file is sourced automatically upon starting up, so if you have macros (or other custom modifications, for that matter) that you would like to have available all the time, edit the .vimrc file (even if you have to create it!) to do so.


next up previous contents
Next: Learning more about Vim Up: The Woodnotes Guide to Previous: Spell Checking   Contents
Randall Wood 2009-08-04