Reputation: 1556
In my ~/.vimrc I have had the following two keybindings to make getting into command mode easier for myself over the past fifteen years:
nmap ; :
vmap ; :
Is there an easy way to do this in emacs evil mode?
I have been reading through the wiki at http://www.emacswiki.org/emacs/Evil and haven't come across the correct way as of yet...
Upvotes: 2
Views: 1096
Reputation: 35318
The command that gets executed when you hit :
is evil-ex
, as you can find out by running:
:describe-key<CR>
:
(i.e. run Emacs' describe-key
command, then hit the key you want info on).
So you can just bind ;
to also run evil-ex
.
(define-key evil-normal-state-map (kbd ";") 'evil-ex)
(define-key evil-visual-state-map (kbd ";") 'evil-ex)
(define-key evil-motion-state-map (kbd ";") 'evil-ex)
In Emacs, just generally, you can define keyboard macros, which are basically the same as how Vim handles mappings:
(global-set-key (kbd ";") (kbd ":"))
In evil-mode, you need to add them to the relevant keymap for the state:
(define-key evil-normal-state-map (kbd ";") (kbd ":"))
(define-key evil-visual-state-map (kbd ";") (kbd ":"))
(define-key evil-motion-state-map (kbd ";") (kbd ":"))
However, for some reason that does bizarre things in this case. It's the first binding I've seen fail in that way. Just use the first version.
Upvotes: 3