I'm trying to create a zsh alias that will start vim and search backwards from the end of the file for a given string. I learnt about +normal and can do something like this to start vim at the end of the file:

vim "+normal G" log

But I'm not able to follow that by an incremental search. The following does work (with a literal CR) from the command line:

vim "+normal G?TEST^M" log

But I can't get this to work with an alias, probably because of the literal carriage return.

2 Answers 2


I would recommend breaking this up into multiple commands. This works for me:

vim log -c "normal G" -c "?TEST"

This doesn't need a carriage return since "?test" is treated as an ex command, not a normal mode command.


You don't need "normal" at all, as Ex-"?" takes an address.

vim log '+$?TEST'

because of the literal carriage return

When you really want a carriage return, you can use "execute". The following is much longer but also works:

vim log '+exe "normal! G?TEST\<CR>"'

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.