2

On line ay, 0dtxdty deletes the a (as I would expect), but :norm dtxdty does nothing, norm! and exec don't change it.

I wanted to use it as part of a command to align as explained here, but to two different characters.

What am I doing wrong and what command will work just like normal mode 0dtxdty?

2

The command

:normal 0dtxdty

stops processing after an error. In your case dtx results in an error, as there is no x on that line.

To ignore this error, use

silent! normal 0dtxdty

But be careful with silent!, you might hide errors, that you want to see.

  • Thank you. Not very important I guess but you included 0 at the beginning of normal which afaik does nothing since normal starts from column 0 anyway. I thought that errors in vim are displayed on the bottom of the screen, which is not the case for dtx nor tx, even :h errors redirects to info about error messages. How can I know about errors in vim if they raise no message/can I somehow make it always display? – Q.Q Feb 15 at 11:55
  • @Q.Q I don't know how to detect this error in a script. I think this is worth another question. Something like "How to detect errors in :normal ...?" with your example. – Ralf Feb 15 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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