[vial-devel] Vim like mappings for Emacs
Brad Beveridge
brad.beveridge at gmail.com
Thu Nov 23 05:54:29 UTC 2006
Hi all,
In my search for a Vim-like editor with strong Slime integration, I
have looked at the Viper mode of Emacs.
If you don't like Emacs for religious or other reasons, you should
stop reading now :)
If the only reason you don't like Emacs is because of the key
bindings, well read on!
Now, I am possibly the most stubborn Vim bigot - I've put a LOT of
effort into alternatives like Slim-vim and Vial. So if I can come
over to the dark side, you ought to maybe have a look :)
I started with Viper mode and added various features to make it more Vim-like.
The notable features I've added are
;;;;;;;;; NEW FEATURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Point movement features, gg
; Scrolling features, zt zb zz
; Search for word features, * #
; Tags support, C-] and C-t
; Undo/redo, u C-r
; Window manipulation, C-wC-w, C-wo, C-wc
; Expand abbreviation, C-n
; Visual mode commands, v, o, O, d, y, c
; New Ex features:
; - split, vsplit, bdelete, bn
Some/most of them are somewhat rough, but they work.
I've only tested on Aquamacs, but I know that if you use vanilla GNU
Emacs you will need to download and install redo.el
(http://www.wonderworks.com/download/redo.el). I think Xemacs will
work.
I've also created more Vim like bindings for the Slime interface.
Check out the slime-mappings.el file for the full list, but generally
they match regular Slime mappings without the C-c prefix.
For example:
C-c C-k : slime-compile-and-load-file : (vip-slime-leader k)
C-c M-k : slime-compile-file : (vip-slime-leader K)
vip-slime-leader is a character that you can define - it defaults to SPACE
The mappings are in a directory called extended-viper, I rename it to
~/.extended-viper. You can get it via Darcs by:
darcs get http://common-lisp.net/project/vial/darcs/extended-viper
One of the main things that does not work is C-c to exit insert mode.
I have personally remapped this to C-g (I type Dvorak and it is right
next to "c"). I strongly recommend using C-g as the abort key because
it is the default to abort Emacs commands and minibuffer entries. I
have also found it beneficial to give up _some_ of the keybinding
bigotry :) For example C-h is a great way to get help. Single
chorded keys for infrequently used commands is not a bad thing.
At the minimum you'll need to add:
(setq viper-mode t)
(require 'viper)
to your .emacs file.
And rename the viper-example file to ~/.viper.
Feed back and patches more than welcome.
Cheers
Brad
--- My .emacs file ----
(setq inferior-lisp-program "/opt/local/bin/sbcl")
(add-to-list 'load-path "/Users/brad/development/lisp/packages/slime")
(require 'slime)
(slime-setup)
(setq viper-mode t)
(require 'viper)
(custom-set-variables
;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(case-fold-search t)
'(current-language-environment "Latin-1")
'(default-input-method "latin-1-prefix")
'(global-font-lock-mode t nil (font-lock))
'(viper-syntax-preference (quote emacs)))
(custom-set-faces
;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
)
(tool-bar-mode -1) ; hide the tool bar
(setq scroll-step 1) ; smooth scrolling
; Brad's Viper changes
; Dvorak mappings for movement
(define-key viper-vi-global-user-map "h" 'viper-next-line)
(define-key viper-vi-global-user-map "t" 'viper-previous-line)
(define-key viper-vi-global-user-map "j" 'viper-backward-char)
(define-key viper-vi-global-user-map "k" 'viper-forward-char)
(define-key viper-vi-global-user-map " d" 'viper-kill-current-buffer)
(setq viper-auto-indent t)
; Let ^H work as help
(setq viper-want-ctl-h-help t)
; I normally use ^C to exit insert mode in Vim, since ^C is used by Emacs so
; much, I'll use the nearest key to it on a Dvorak keyboard. Handily it is also
; the quit key for minibuffer commands
(define-key viper-insert-global-user-map "\C-g" 'viper-intercept-ESC-key)
More information about the Vial-devel
mailing list