How to reassign prefix keys "c", "d", etc. In Emacs viper mode

I am using the Colemak keyboard layout and want to try the Vim layout from here with Vimpulse. However, the layout reassigns the Vim keys 'c' and 'd' command prefix among others, and these keys do not seem to be easily reprogrammed with the standard Viper key redirection command. They are all mapped to the viper-command-argument argument in the viper’s key card, and the actual key functions are apparently defined elsewhere in the Viper source.

Is there an easier way to reassign prefix commands to other keys than expand my local copy of the Viper source and override the prefix key values ​​in it?

+4
source share
2 answers

Evil-mode seems to support reassignment of even prefix key commands. I use this instead.

+1
source

The Viper-mode command prefix keys are configured using two sets of indirect links. You found the first, as in all command keys bound to 'viper-command-argument . The next thing to do is look at the viper-exec-array variable. It is currently installed as follows:

 (aset viper-exec-array ?c 'viper-exec-change) (aset viper-exec-array ?C 'viper-exec-Change) (aset viper-exec-array ?d 'viper-exec-delete) (aset viper-exec-array ?D 'viper-exec-Delete) (aset viper-exec-array ?y 'viper-exec-yank) (aset viper-exec-array ?Y 'viper-exec-Yank) (aset viper-exec-array ?r 'viper-exec-dummy) (aset viper-exec-array ?! 'viper-exec-bang) (aset viper-exec-array ?< 'viper-exec-shift) (aset viper-exec-array ?> 'viper-exec-shift) (aset viper-exec-array ?= 'viper-exec-equals) 

So, if you want to make the key t act like the delete command, you will need the following two things:

 (aset viper-exec-array ?t 'viper-exec-delete) (define-key viper-vi-basic-map "t" 'viper-command-argument) 

(And, presumably, you will return the movement from t to something, say, with the c key with:

 (define-key viper-vi-basic-map "c" 'viper-goto-char-forward) 

Finally, you need to change the procedure 'viper-prefix-arg-com , which I do not pretend to fully understand. However, if you replace all ?c with ?t , the t binding works as expected. (Alternatively, you can add ?t in the same way that ?c ). I would provide a source for this, but it is 100 lines long and should not be included here (this is a 4 character change). You can get to the source by running Mx find-function viper-prefix-arg-com .

In short, if you want to do wholesale key binding for a viper, it will be quite a lot of work, and you will become much more familiar with the viper source code.

Having looked at the path 'viper-prefix-arg-com , you cannot make the desired change without overriding it. There are probably 3 or 4 other types of vi commands that are implemented in viper-mode (this is the "command argument"). The rest, we hope, are more straightforward to respond ...

+2
source

Source: https://habr.com/ru/post/1299518/


All Articles