If I run:

:w !node

It will take my current buffer and send it to stdin and run the code in node.

If I run:

:redir @+ | echo "bob" | redir END

It ends up on the system clipboard.

But if I want to copy the output to the clipboard, by running:

:redir @+ | w !node | redir END

It seems the input from the current buffer does not reach node, and that it tries to run redir as a command from bash for some reason.

:redir @+ | w !node | redir END
/bin/bash: redir: command not found
      throw er; // Unhandled 'error' event

Error: write EPIPE
    at exports._errnoException (util.js:907:11)
    at WriteWrap.afterWrite (net.js:790:14)

shell returned 127

Is there some other way to do this?

1 Answer 1


Everything after ! will be a command, including |. So what you're running is:

:redir @+
:w !node | redir END

This makes sense, since using | is shell commands is common to pipe output.

The easiest workaround is to use multiple lines:

:redir @+
:w !node
:redir END

or you can use :execute to work around this:

:redir @+ | :exe 'w !node' | redir END

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.