1

Scenario. Imagine, that I want to search replace something.

:%s/foo/bar/g

Now, imagine that I made a mistype and executed the command

:%s/fop/bar/g

Every vim user knows than @: executes the last command, what if I want to modify last command and then - execute?

As an extended question, is it possible to navigate through the history like does q: and then select the command and modify it before executing?

Thank you.

3

I would recall the previous command-line via <Up> in command-line mode, and then do inline editing, switching to the command-line window (with full Vim commands) via <C-F> if necessary. Or just do q:k, which is equivalent.

Note that you cannot directly modify @:, because it is a read-only register.

  • Thank you Ingo. You probably does mean q:k command. Also I don't understand <C-F>, if it's pressing Control+F in command mode , then it's not working – CEO at Apartico Dec 4 '15 at 20:53

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.