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:

#!/bin/bash
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.


About the author: My name is Miikka Koskinen. I'm an experienced software engineer and consultant focused on solving problems in storing data in cloud: ingesting the data, storing it efficiently, scaling the processing, and optimizing the costs.

Could you use help with that? Get in touch at miikka@jacksnipe.fi.

Want to get these articles to your inbox? Subscribe to the newsletter: