0

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 ?

2 Answers 2

2

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"
Sign up to request clarification or add additional context in comments.

Comments

0

I'm not sure you can pull that off with :execute. But you can use Clam (e.g. :Clam ls) as a basis and edit plugin/clam.vim in order to fire a gg after execution of the shell command.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.