5

Many times I find my self running ciw or c2W but with different text. Like ciwnewtext<esc> and then ciwanothertext<esc>. The dot command . will repeat the whole change (it does not allow me to specify the text).

For simple motions like iw it does not bother my much but sometimes I use more complex motion that I would like to reuse right away. Is there any way to accomplish that?

2
  • Could you provide examples on what you call 'more complex motion' and what would the 'magic command' do?
    – mMontu
    Jan 23, 2017 at 12:41
  • motions like 3fJ or \longword Jan 23, 2017 at 12:47

1 Answer 1

3

If you movement involves searches on the current line (:help f or :help t) you could repeat that movements with ; and ,:

cfxnewtext
c;anothertext

For regular searches you could use n:

c/xyz<enter>newtext
cnanothertext

If you are using a combination of searches and movements, like search for pattern1 and then jump some sentences/words, you could record a macro:

qq<complex movements>c2w<c-o>q

The i_CTRL-O allows you to finish the macro while in insert mode. Then you can play the macro using @q (or @@) and you will end in insert mode with the old text already removed.

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.