开发者

viper-mode changes <delete> key

I want to use the <delete> key (C-d, I think) for forward-deletion in viper-mode.

Before starting viper-mode, <delete> works c开发者_Python百科orrectly. In viper-mode, <delete> jumps to the buffer's last line.

I have added (setq viper-ex-style-editing nil) to .viper and <backspace> works in all modes.


Try this:

(define-key viper-vi-basic-map "\C-d" 'viper-delete-char)
(define-key viper-insert-basic-map "\C-d" 'viper-delete-char)

Now, that uses the viper-delete-char command to be consistent with viper. If you want the regular emacs deletion behavior, use delete-char instead.

viper is implemented using a bunch of different keymaps, and figuring out which ones to modify is tricky. The easiest way (usually) is to just look at the source code. So you could start with M-x find-library viper. Note: Most keymaps are actually defined in the library viper-cmd.


The \ key will switch back to Emacs mode for a single key stroke, so you can do what you are seeking with "\<delete>" without making any changes or adding any code to your .emacs file.


Okay, here's what you do.

(1) In viper mode, use C-h k to find out what <delete> is bound to. Just in case you want it attached to some other key.

(2) In some other mode, use C-h k to find out what the name of the function is that does what you want. I think it's delete-forward but don't trust me, check. RMS has an annoying tendency to rename things.

(3) Back in a viper-mode buffer use M-x local-set-key to set to what you want. Try it.

(4) If you're happy add this code to your .emacs

(defun fix-del-key-in-viper-mode ()
  (define-key viper-mode-map "<delete>" your-desired-function))
(add-hook viper-mode-hooks fix-del-key-in-viper-mode)

Warning, you may have to mess about with this a bit as I haven't tested it. In particular make sure it's really viper-mode-map and not something else, as the naming conventino isn't consistently followed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜