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?
read !one atomic thing or decomposable asreadand!? I looked athelp readand read no further :/ – Greg Nisbet Mar 13 '17 at 02:09!would also affect:r!.But that doesn't mean the combination may not have its own special properties. – muru Mar 13 '17 at 02:11sh::r! sh -c '....' 2>/dev/null. Otherwise you'd have to write a function. – muru Mar 13 '17 at 02:21