I use the following to edit contents of my clipboard:
pbpaste | vipe | pbcopy
Where vipe is a util for inserting your editor (vim) in the middle of a pipe. From: https://joeyh.name/code/moreutils/