4

Using an exotic keyboard layout, I have to remap g (among others) which is, on my layout, in the h position on a classic qwerty layout. To do so I decided to swap g with h with the following commands:

noremap g h
noremap h g

This doesn't work. For instance typing hh is viewed as gh and not gg. Also when hitting g it shows g (with showcmd enabled) and not h and it doesn't seem to take the remapping into account, it act like the g command. But when hitting g again or waiting 1 second it actually moves left.

I tried the following to make it work in operation-pending mode

onoremap g h
onoremap h g

but it doesn't change anything.

So why does it behaves that way? And how to fix it?

bootleg
  • 187
  • 7

1 Answers1

3

The trouble with multi-key commands like gg (or the various <C-w> commands from which I remember a similar issue) is that they are not the g command followed by a g operator. (Especially with the g prefix, there's a whole range of unrelated commands not found in the original vi in that space.)

I'm afraid you'll have to define separate remappings for all of them:

:nnoremap hh gg
...
Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • Well that's a shame. And although it sort of answers the question, it doesn't explain the behaviour I described (the g remap that doesn't work even in normal mode) which is the most annoying. Thanks anyway. – bootleg Apr 22 '13 at 13:58