0

I'm using CTRL + n to do auto-completion when editing - since years.

One things that annoys me (and now I want the solution) is that the completion is not replaced characters until the next non-letter-characters (everything else than 0-9a-zA-Z_ for me).

For exemple, I have the following line:

auto a = obj->getSomething()

I want to change the called method to getString. I'll put my cursor right behind the S and press CTRL + n until the right method appears and I select it with ENTER. Here is what I end up with

auto a = obj->getStringomethingNumber()

Ideally vim would have replaced everything up to ( with the method-name, so to get it directly, without have to do dw manually.

auto a = obj->getString()

How can achieve this?

  • Starting on the S, hit l (right char) ce and then Ctrl n – D. Ben Knoble Feb 10 '18 at 8:53
  • Thanks, didn't know ce, but how to combine it with CTRL-n, or maybe replacing CTRL-n. And while being in insert-mode. – Patrick B. Feb 10 '18 at 13:10
  • I think youre confusing a bit the vim philosophy. I see two steps here: changing the method name (leaving us in insert mode) and then using completion. Hence i suggest normal c{motion} and then hit your completion. Navigate and edit in normal. Type in insert. – D. Ben Knoble Feb 10 '18 at 21:44
  • When hitting CTRL-N I'm in insert-mode, that would make it: ESC-ce-CTRL-N. Which I could map into a shortcut - maybe replace CTRL-N itself with it. That's maybe the answer I'm looking for. – Patrick B. Feb 11 '18 at 22:21
  • My point is why are you navigating to the S in insert mode. Thats what normal mode is for – D. Ben Knoble Feb 11 '18 at 22:22

Your Answer

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

Browse other questions tagged or ask your own question.