Meninx Meninx - 1 year ago 125
Bash Question

vim - execute - shell command?

I want to add a mapping which will visualize the output of a shell command in a new window.
the problem is the command is interrupted when moving the cursor to the top of the file.

:execute ":new \| set nonu \| 0r ! ls \| normal! gg"

I figured out that the problem is with the execute command which considers the part from the symbol
to the rest of it as a shell command (
ls | normal! gg
) and that's why it shows an error when being executed.

How to prevent that ?

Answer Source

When a command doesn't accept <bar> to separate the command. The normal way to fix this is wrap the command in a execute which does except bars

:execute ":new \| set nonu \| execute '0r ! ls' \| normal! gg"