Create a Vim quickfix list from the clipboard

Posted on May 7, 2020

Do you find yourself editing a buffer containing file paths and you want to quickly switch between them?

The :cex[pr][!} {expr} command executes any valid vim expression ({expr}) and constructs a quickfix list from each string of the output.

Assuming you’ve set clipboard to unnamed or unamedplus, you can supply the clipboard register (@*, or @+ respectively) as a vim expression.

1
2
"assuming :set clipboard=unnamed
:cex @*

or:

"assuming :set clipboard=unnamedplus
:cex @+

Now you can set the quickfix to the current contents of your clipboard, note that your input will still have to match your errorformat.