2

I'm using vertigo with evil in the following way:

(evil-define-motion vertigo-j (count)
  "Evil vertigo motion. Count has no effect."
  (vertigo--jump #'evil-next-line "Jump down: "))

...and I map it to j with:

(define-key evil-normal-state-map (kbd "j") #'vertigo-j)
(define-key evil-visual-state-map (kbd "j") #'vertigo-j)
(define-key evil-motion-state-map (kbd "j") #'vertigo-j)

It works well enough for normal motion, but when I try to delete some lines (with dj), something strange happens. I go from:

1  It was on ▊a dreary
2  night of November that I
3  beheld the accomplishment
4  of my toils.  With an
5  anxiety that almost
6  amounted to agony, I
7  collected the instruments...

(where is point), and, by pressing dj and f (delete down 4 lines), I get:

1  It was on ▊at almost
2  amounted to agony, I
3  collected the instruments...

What should have happened is that the whole of the first line was deleted, along with the whole of line 5:

1  ▊amounted to agony, I
2  collected the instruments...    

What is incorrect about my remapping, and how can I fix it to get the desired behaviour?

1
  • 1
    When defining a motion (evil-define-motion), Evil's info manual (section 5.1) shows that you can also set its type, e.g. type: line so that "the range is expanded to linewise positions" - if that's what you want (see also the 'block' type). I didn't test this, but I think that's what you're after. And if we're here, perhaps you also want to set :jump t.
    – VanLaser
    Jun 24, 2016 at 10:35

1 Answer 1

1

When defining a motion (evil-define-motion), Evil's info manual (section 5.1) shows that you can also set its type, e.g. type: line so that "the range is expanded to linewise positions".

This seems to work:

(evil-define-motion vertigo-j (count)
  :type line
  :jump t
  "Evil vertigo motion. Count has no effect."
    (vertigo-jump-down))

;; example mapping
(define-key evil-motion-state-map (kbd "g j") #'vertigo-j)

In my case, I couldn't even use vertigo--jump (?), so I simply relied on the example provided by the plugin author.

Now, something like dgjaa will delete entire lines. Using vgjaad will not delete entire lines though - but this is OK, since with visual mode, the user controls the type of selection (so, you can use Vgjaad instead).

3
  • 1
    You have to (require 'vertigo) to get vertigo--jump, as it's not autoloaded.
    – digitalis_
    Jun 24, 2016 at 18:24
  • 1
    However, your answer fixes the problem perfectly!
    – digitalis_
    Jun 24, 2016 at 18:31
  • Glad it worked - I edited it a little to add the bit of useful info from the original comment.
    – VanLaser
    Jun 24, 2016 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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