I have a binding in my .vimrc
that reads the contents of the system clipboard to a line immediately below my cursor
nnoremap <silent> <leader>f <esc> :read ! test -f /usr/bin/xsel && /usr/bin/xsel -ob \|\| /usr/bin/pbpaste<cr>
I tried to change it to (1)
nnoremap <silent> <leader>f <esc> :read ! /usr/bin/xsel -ob \|\| /usr/bin/pbpaste<cr>
or (2)
nnoremap <silent> <leader>f <esc> :read ! /usr/bin/xsel -ob ; /usr/bin/pbpaste<cr>
for the sake of simplicity, even though it's more brittle.
When I change it to either of those, however, I get the contents of stderr in my buffer as well, as if vim
is reading from both stdout
and stderr
when executing the command. (this is after echo clipboard_contents | pbcopy
).
/bin/sh: /usr/bin/xsel: No such file or directory
clipboard_contents
Why is vim doing that? Is there a way to tell it to silently drop stderr in this case or redirect it to /dev/null
?