2

This list of call-interactively actually represents a very simple Vim macro: vk=o

(define-key evil-normal-state-map (kbd "SPC dg")
  (lambda ()
    (interactive)
    (call-interactively 'evil-visual-char)
    (call-interactively 'evil-previous-line)
    (call-interactively 'indent-region)
    (call-interactively 'evil-open-below)))

Question
Is there a simple way to execute vim commands inside elisp?

Notes
I have found that you can bind vim macros to keyboard shortcuts using global-set-key. Something like this: (global-set-key (kbd "C-c C-l") "vk=o") But trying to see how global-set-key was doing it, it lead me to compiled C code from define-key which didn't help much.

I am looking to write something perhaps alike:

(define-key evil-normal-state-map (kbd "SPC dg")
  (lambda ()
    (interactive)
    ;; some code
    (eval-vim-macro "vk=o")))

Thanks for the help!

Mikechaos
  • 359
  • 4
  • 18
  • Try defining the binding to be a string instead of a lambda: `(define-key evil-normal-state-map (kbd "Q") "jjjo")`. – Gordon Gustafson Sep 30 '17 at 21:11
  • I can already accomplish this (though I used `global-set-key`) and bind and specific key combination to a given string representing vim commands. What I'm looking for is a way to bind to something I can reuse in a function definition so I can use some of my currently defined kbd macros directly inside my elisp code! – Mikechaos Oct 03 '17 at 00:16

0 Answers0