[slim-vim] Vim like mappings for Emacs

Tomas Zellerin zellerin at gmail.com
Thu Nov 30 10:46:49 CST 2006


On 11/30/06, Brad Beveridge <brad.beveridge at gmail.com> wrote:
> On 22/11/06, Brad Beveridge <brad.beveridge at gmail.com> wrote:
> > 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)
> >
>
> No comments at all?
>

Ok, so some comments I wanted to postpone before I summarize them and
formulate better, but you asked.

I quite closely followed each of your Lisp/vim attempts. So I tried
the last one as well. I found that I can use with some (often great)
pain the modified viper mode, and that the coding is probably more
efficient than my previous favourite setup (clisp + modified readline
settings and vim). I love <Space-e>.

The rest of mail contains some detailed complains I recall. I suppose
they all can be fixed, but I dont have time to learn how at the
moment. It's from memory, so I apologize if something is not
completely correct.

I miss Ctrl-P (I use it more often than Ctrl-N, because I tend to
repeat what I wrote above, not below).

I miss Ctrl-X Ctrl-F (and it hurts when it wants to load new file). I
am not sure whether gf works.

:sp used to take an argument on vim, and I used to rely on it,

In lisp repl window, sometimes ":" ceases to work (goes to ex mode,
cant be written into buffer).

I miss visual mode (oh, I see it should work - i tried only V, not v).

I miss =.

Escape works strangely and does not always cause leaving insert mode
(especially Esc-x, seems to behave like Meta-X).


More information about the slim-vim mailing list