0

In Some Thoughts on Emacs and Vim, Shinobu recommendation to remap <space> and <backspace> doesn't work on Emacs 2.3.1 with Vimpulse 0.5.

What am I doing wrong?

;; from .emacs

; simulate vim's "nnoremap <space> 10<c-e>10j"
(vimpulse-map " " (lambda ()
                     (interactive)
                     (next-line 10)
                     (viper-scroll-up-one 10)
                     ))

; simulate vim's "nnoremap <backspace> 10<c-y>10k"
(define-key viper-vi-global-user-map [backspace] (lambda ()
                     (interactive)
                     (previous-line 10)
                     (viper-scroll-down-one 10)
                     ))
Natan Yellin
  • 6,063
  • 5
  • 38
  • 57

1 Answers1

1

It'd help to know what isn't working.

The following works for me, as in SPC and backspace scroll by 10 when in command mode (Vi state):

(define-key viper-vi-global-user-map [backspace]
  (lambda ()
    (interactive)
    (previous-line 10)
    (viper-scroll-down-one 10)))

(define-key viper-vi-global-user-map (kbd "SPC")
  (lambda ()
    (interactive)
    (next-line 10)
    (viper-scroll-up-one 10)))

That's using vimpulse.el version 0.5 and viper-expert-level 5.

Trey Jackson
  • 73,529
  • 11
  • 197
  • 229
  • That works. Should I ever use (vimpulse-map) in place of (define-key)? – Natan Yellin Jul 28 '11 at 15:21
  • @Natan I'm not a vimpulse expert, so I don't know when `vimpulse-map` is useful or not. – Trey Jackson Jul 28 '11 at 15:39
  • OK. Last question: How did you know to use `[backspace]` and not ``? According to `C-h k` `` is the correct binding, yet only `[backspace]` works. – Natan Yellin Jul 28 '11 at 15:43
  • 1
    Actually, what I'd prefer to use is a call to `kbd`, which is much easier to use. You're almost there. Once you've done the `C-h k`, you correctly saw that the key maps to ``, now, to use that in the call to `define-key`, you just do `(kbd "")` (basically cut/paste from the *Help* buffer into the string passed to kbd. I wasn't 100% sure the key you were hitting was the same as that, but I'll update the answer appropriately. – Trey Jackson Jul 28 '11 at 16:03
  • Great. Thank you for helping me solve future questions on my own. – Natan Yellin Jul 28 '11 at 16:20