6

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.

  • 4
    In general, this translation is not going to be trivial. Things are done very differently in Emacs, but I think you'll find that Emacs is much cleaner and more powerful in the long-run, although it's a good deal more verbose. – PythonNut Feb 24 '16 at 4:51
  • 4
    I think it might be better for you to ask questions about specific corresponding lines from your .vimrc, rather than a catch-all question. – PythonNut Feb 24 '16 at 4:57
  • 1
    so one cannot just "run the .vimrc script I had when text editor in Evil opens up? – Pinocchio Jan 20 at 19:57
4

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)
  • How did you know the command was evil-shift-right-line? Experience or is there a library? – Jason Basanese Feb 24 '16 at 4:57
  • 2
    In general, you can use C-h k to determine what command a key runs. However evil 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 an evil operation that works on a whole line is usually <op>-line. Examples include evil-delete-line, evil-yank-line. Some operations, like evil-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
  • 1
    so one cannot just "run the .vimrc script I had when text editor in Evil opens up? – Pinocchio Jan 20 at 19:57
  • @Pinocchio that is correct. – PythonNut Jan 22 at 19:58
  • Why cant i run it? – Pinocchio Jan 22 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.