2

Problem: I want to be able to quickly remove the last typed word while remaining in the Insert mode. However, i_CTRL-W seems to be using WORD definition of a word. I.e. it is not possible to just remove 'word' in word-word-word even with iskeyword=@,48-57,192-255,_,-

In :help i_CTRL-W, I'm advised to See the section "word motions", |word-motions|, for the definition of a word. It is however unclear how its contents apply to i_CTRL-W.

Is there any way to achieve the desired behavior?

  • 4
    Not for me. Can you reproduce this behaviour with vim -Nu NONE? If not, it might be a plugin or mapping at work. – muru Feb 25 '16 at 13:27
  • 1
    If you can, include the output of :verb imap <C-w> in your post. If a plugin has modified the behavior of <C-w>, maybe its filename will appear. – saginaw Feb 25 '16 at 14:38
  • @saginaw: Adding :verb in front of a map command to see where was the mapping made is a pretty cool trick! I don't remember seeing something like this on this site maybe that would be worth a self-answered question or something like that. – statox Feb 25 '16 at 15:10
  • @statox Thank you very much ! But I think the question / answer has already been done here: vi.stackexchange.com/a/279/4939 – saginaw Feb 25 '16 at 15:20
  • Thanks for hints! Works as intended. This was my misinterpretation of iskeyword. Posted an answer just in case someone makes the same mistake. – meekreau Feb 25 '16 at 15:41
3

As pointed out by comments to the question, iskeyword actually has to influence i_CTRL-W behavior and it indeed does. This was my misinterpretation of iskeyword being a set of delimiters but it is of course a set of word characters instead.

So no wonder that having a '-' in iskeyword does not remove a single instance of 'word' from word-word-word but all of it at once because it is considered to be a single word.

  • Maybe I was unclear. When I said, not for me, I meant that <c-w> did delete only up to -, it did not delete all of it. – muru Feb 25 '16 at 17:19
  • If I fire up vim -Nu NONE, then - is not in iskeyword and vim does not delete word-word-word at once but only the last word up to -. But in my question I used iskeyword with - and I wondered why this deletes all of it. – meekreau Feb 25 '16 at 18:14

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.