I have heard of the power of Emacs, but I have a ton more experience with vim and an extensive amount of shortcuts in my .vimrc
file. I would like to transfer these mappings over to Emacs evil-mode
. What would be the best way to do this? One example would be mapping tab to >> (indenting the current line). Which looks like nnoremap <tab> >>
in my .vimrc.
Taken literally, your sample line would translate to the following:
(define-key evil-normal-state-map (kbd "<tab>") (kbd ">>"))
Although I don't personally recommend this. It's much cleaner to reference the function you want to run by name instead of using a keyboard macro. This clears up the need for a distinction between nmap
and nnoremap
, and is more fault-tolerant.
(define-key evil-normal-state-map (kbd "<tab>") #'evil-shift-right-line)
-
1How did you know the command was evil-shift-right-line? Experience or is there a library? – Jason Basanese Feb 24 '16 at 4:57
-
2In general, you can use
C-h k
to determine what command a key runs. Howeverevil
does hide some things behind proxy-commands (e.g.evil-shift-right
) to make the composable grammar easier. In this case, you just have to know that anevil
operation that works on a whole line is usually<op>-line
. Examples includeevil-delete-line
,evil-yank-line
. Some operations, likeevil-downcase
do not define such convenient aliases, so you need more magic to get them to work. Ask if you need help for those. – PythonNut Feb 24 '16 at 5:00 -
1so one cannot just "run the
.vimrc
script I had when text editor in Evil opens up? – Pinocchio Jan 20 '19 at 19:57 -
-
.vimrc
, rather than a catch-all question. – PythonNut Feb 24 '16 at 4:57.vimrc
script I had when text editor in Evil opens up? – Pinocchio Jan 20 '19 at 19:57