4

Sadly over time a few of my mappings have ended up overlapping.

For example I toggle wrapping with \w but I later introduced a mapping on \wi.

As a result, when I press \w, Vim waits for some time to see if I will follow it with i.

Since I usually don't want to wait, I will often hit Space to force Vim to recognise that no i is forthcoming.

But of course hitting Space has the minor side effect of pushing me forwards one character.

So is there a better keystroke I could use than Space which would result in no action being taken?

I accept that this might be a two-keystroke operation. An example could be y Escape, which I assume does nothing. But a better choice would be easier to hit (Escape is a long way to reach) and possibly use a meta combination (Ctrl-C is faster/easier to perform than CtrlC, isn't it?).

2 Answers 2

6

It seems any key you map to <Nop> correctly terminates the mapping, without doing anything else. With

set notimeout
inoremap w foo
inoremap ww bar
inoremap <space> <Nop>

You can use w<space> to insert foo, and ww to insert bar. Of course, this would be the same as mapping w<space> in the first place, expect for the fact the "mapping-completion-key" is generic.

1

I am considering using jk to end the timeout.

These are pretty easy to hit, and usually leave me back where I started.

The one exception is if I was sitting on the last line of a file, then jk will ring the bell, and leave me on the line before last.

(For my most common use case, they are also conveniently on the opposite hand from \w).

Your Answer

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

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