Tech Tips

Keyboard Maestro – Paste into Vim (with formatting)

Vim users frequently run   :set paste  and :set nopaste . Using paste mode makes it simple to paste text while maintaining whitespace, but some other aspects of Vim are reset in paste mode (e.g., autoindent and smartindent). I’m sure there’s a way to make it easier to flip back and forth within Vim (via .vimrc), but if you want a universal way to do this, regardless of the Vim settings that are in place, you may find the following Keyboard Maestro macro helpful.

Using it is easy. Simply position the cursor where you want to paste (presumably in insert mode) and hit CTRL-ALT-CMD-V. The macro will enter paste mode, paste the text, then jump back out of paste mode. It’s very quick and makes it a no-brainer to paste into Vim. Naturally it could be done better, but this is working great… please let me know in the comments if you have a cleaner solution! I’ll update this post if I ever find the need to modify the macro.


Leave a Reply

Your email address will not be published.