1

Related to but not duplicate¹ of Bundling command sequences together for repeat (.).

The point (.) command is really useful to redo the last action (insertion, replacement, etc.).

Sometimes I find myself making a small mistake that prevent me from repeating the action (because the mistake would be repeated). Is it possible to fix that mistake so that the fix is not considered to be the last action but instead added to the previous last action ?

For example, when editing the block:

triangles[0] = ...
triangles[1] = ...
triangles[2] = ...

To replace triangles by polygons without the :s command: I go to the first t, then hit c then type polygon (mistake: no s) then esc. Then I realize my mistake: I have to go back to the p then change to polygons. Instead of doing that I would like to just press a key to amend the last action, then i then s. Finally I would use the . key to repeat on the two last t.

¹ That question asks to repeat the last N commands/action instead of just the last one while I would like not to create a new command/action but modify the previous one.

1
  • You can sort of do this using the RepeatLast plugin that I described in my answer to your other question (see the plugin's \G command, and look into how to edit the contents of registers before replaying them) However, doing so would in all real-world circumstances be more effort than just pressing u and retyping your c command correctly.
    – Rich
    Sep 11, 2017 at 14:07

1 Answer 1

0

I doubt it. Take a look at this thread: Is there a way to repeat the pænultimate (or older) change?. Even though the discussion is about something a bit different from what you've mentioned you can deduce that the single repeat mechanism is pretty limited.

The closest thing I can think of would involve a macro. You'd have to remember to start recording before you begin a complex edit. Then if you make a mistake along the lines of your example you can edit the macro and correct it. Then you can repeat to your heart's content with @{register} and @@. Editing is possible because a macro is just a series of keystrokes stored in a regular register. But I'm guessing you won't consider this an adequate substitute for what you want to do.

1
  • Thanks. I will add an answer if I write an useful macro. Sep 3, 2017 at 9:52

Your Answer

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

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