I'm trying to learn emacs, getting vi custom key bindings.
Using Viper-mode, what is the correct way to re-bind a key? (I'm using Colemak keyboard layout(instead of qwerty) so have to change things like n->j) But would like it to work in viper-mode.
From this key binding guide on GNU.org: http://www.gnu.org/software/emacs/manual/html_node/viper/Key-Bindings.html
It says the command to put in your .viper file is:
(define-key viper-vi-global-user-map "\C-v" 'scroll-down)
It doesn't work for me... in fact not sure I even have the function "define-key"...
M-x define-key [No match]
I'm not sure if 'define-key' is available on my version of emacs?
This works, but not in viper-mode
(global-set-key "n" "j")
Any help would be much appreciated. This is my first day using Emacs, to it's a pain getting Colemak & Viper-mode to work properly.
Thank for any help...
Hopefully some useful answers here:
First, having that line in the
.viperworks for me. Note that theviper-vi-global-user-mapapplies when you're in command mode, not insert mode.Secondly,
define-keyisn't a command, it's a regular function, which just means that it cannot be called using M-x. See this Emacs wiki page for a little more detail on that distinction. But that was a good attempt.Third, the
global-set-keyis a command, you could have tried making a change using M-x global-set-key. But, that sets the key in the current global map, which isn't the same asviper-vi-global-user-map. Viper-mode uses a bunch of different keymaps to make Emacs behave like vi, but all of the maps are overlaid on top of the global map.I'm guessing that you found that C-v wasn't bound like you want when you're in insert mode. And that can be solved by adding this to your
.viper:Lastly,
scroll-downmay not be what you want. Thedownrefers to the text moving down (given the perspective of a fixed window). C-v is generally bound to'scroll-up. But,maybe it is exactly what you want.Caveat: I'm not a viper-mode user, I don't even know how to use vi. So my terminology may be off. But I find the challenge of changing things in viper-mode very interesting.
Edited to add
From your comment it sounds like you want n to be the same as what j is bound to by default. Try adding this:
In "normal" mode I did M-x describe-key j, which told me that j is bound to
'viper-next-line, and the above line will bind n to the same routine. Repeat for the rest of the bindings you want to shift around.