2

The command looks like this

autocmd! BufWritePost <buffer> mark s | $r ! ruby % | sed 's/^/\#=> /' | 's

It will append the output and move cursor to the original position, before appending.

This is the error I got:

Error detected while processing BufWritePost Auto commands for "<buffer=1>":
E485: Can't read file /var/folders/fw/045tt2q10zv1qkbfbw73y8c80000gn/T/vCDqw9b/7

If remove | 's at the end of line, it works fine, but no returning to the marked s position.

1 Answer 1

3

There are two problems:

  1. The :read ! ... command cannot be concatenated with other Vim commands; it treats all following text as the command to execute. This causes the shell error. See :help :bar. You can fix this by wrapping with :execute.
  2. 's is a normal mode command; to use it in a command-line, you need to prefix the :normal Ex command.
autocmd! BufWritePost <buffer> mark s | execute "$r ! ruby % | sed 's/^/\#=> /' " | normal! 's
Sign up to request clarification or add additional context in comments.

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.