1

I'd like to execute an evil-ex command from another command. Specifically, I'd like to do :'<,'>move'>+1 but when I do, it doesn't quite do the right thing. Instead of moving the text down, it moves it one line from the top of the file.

Here's what I'm using:

(defun evil-visual-move-line-down ()
  (interactive)
  (evil-ex-call-command
   (evil-ex-range (evil-ex-line (evil-ex-marker "<") nil)
                  (evil-ex-line (evil-ex-marker ">") nil)) "move" "'>+1"))
(define-key evil-visual-state-map (kbd "J") 'evil-visual-move-line-down)
0

From Frank Fischer himself:

(define-key evil-visual-state-map "J"
  (concat ":m '>+1" (kbd "RET") "gv=gv"))
(define-key evil-visual-state-map "K"
  (concat ":m '<-2" (kbd "RET") "gv=gv"))
| improve this answer | |
  • If this post solved your problem, could you accept your own answer so we can mark it as done, please? – Dan Apr 5 '16 at 21:57

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.