Vim: replace two characters in standby operation

Using an exotic keyboard layout, I have to reassign g (among other things), which is on my layout, to position h on the classic qwerty layout. To do this, I decided to replace g with h with the following commands:

noremap gh noremap hg 

This does not work. For example, the input hh is treated as gh, not gg. Also, when g is pressed, g is displayed (with showcmd turned showcmd ), not h, and it seems that it does not account for reassignment, it acts like the g command. But when you press g again or wait for 1 second, it actually moves to the left.

I tried the following to make it standby operation

 onoremap gh onoremap hg 

but it does not change anything.

So why does it behave this way? And how to fix it?

+4
source share
1 answer

The problem with multiple-key commands, such as gg (or the various <Cw> commands from which I remember a similar problem), is that they are not a g command, followed by the g operator. (Especially with the g prefix, there are a number of unrelated commands not found in the original vi in ​​this space.)

I am afraid you will have to define separate reprints for all of them:

 :nnoremap hh gg ... 
+3
source

All Articles