Edit clipboard contents in Vim

Wouldn’t it be handy to be able to edit the contents of the clipboard in a text editor? Yes, it would, or at least I do it all the time. For example, I do it when I want to copy text from one website to another website, but I need to reformat it a bit first. For macOS, I have a script called pbedit. It is super-simple:

pbpaste | vipe | pbcopy

vipe is a small program that launches $EDITOR and allows you to edit the data piped between two programs. It’s part of moreutils, which Homebrew users can install with brew install moreutils. pbpaste and pbcopy are the built-in macOS command-line tools for pasting and copying the clipboard.

Try this, or if you’re a Linux user, fashion its equivalent with xclip. Soon you’ll find yourself using it all the time.

Comments or questions? Tweet to me or send me an e-mail.