Skip to content

Latest commit

 

History

History
51 lines (35 loc) · 5.26 KB

README.org

File metadata and controls

51 lines (35 loc) · 5.26 KB

About

vertigo.el is a port of the vim vertigo plugin and gives commands for jumping up and down by lines using the home row. Note that this package does not require evil. In addition to the functionality provided by the vim vertigo plugin, this package also allows setting a digit argument for the next command with the home row.

For example, after pressing a key bound to a vertigo command, the user might press k, the 8th letter on the home row, to jump 8 lines. Vertigo is most useful when used with relative line numbering.

The main difference from using avy is that you can be guaranteed the keys you press will jump the same number of lines consistently. Vertigo also has directional commands instead of commands for the whole buffer (but this can be changed), and requires fewer keypresses in some instances (e.g. jumping 4-10 lines).

I previously had a disclaimer about relative line numbering having issues in Emacs (speed and interaction with other packages that use the fringe), but this is no longer an issue since builtin line numbers were added. I personally have (globally) bound a thumb key + the home row keys to numbers, so I no longer use this package or avy for line navigation. I navigate to a specific character (often with some motion) more frequently than to a specific line, and for that, I do often use avy. That said, I will continue to maintain this package, so feel free to make issues.

Additional Behavior

Setting the Digit Argument

Since the vim vertigo plugin basically just provided an alternate way to set the count for j and k, I thought it might be nice to generalize this behavior to set the count for any command. Vertigo provides vertigo-set-digit-argument, which allows setting the digit argument using vertigo’s configured home row keys. With the universal argument (or any argument), it will set the prefix argument for the next command to a negative number instead. vertigo-set-negative-digit-argument has the opposite behavior, defaulting to a negative argument.

There is also vertigo-run-command-with-digit-argument (suggested/created by Daniel Oosthuizen) which could be considered to be the reverse of vertigo-set-digit-argument. First the user types the keys for the desired command, and then vertigo will prompt for keys to determine the digit argument. There is an alternate version, vertigo-alt-run-command-with-digit-argument, that will display a message afterwards showing the keys run and digit argument used (e.g. “gk 5”). The main difference to the user is that this command requires that M-[0-9] be mapped to digit-argument, which is the case by default. I could probably do something ugly with set-transient-map to ensure this command worked even if the user had remapped these keys, but I’d rather not.

Evil Motions

Vertigo currently has no evil related functionality or dependency. However, if you wanted to use vertigo commands with operators, it is quite simple to make a motion:

;; delete up to a line
(evil-define-motion vertigo-evil-down (count)
  "Evil vertigo motion. Count has no effect."
  (vertigo-jump-down))

;; delete up to and including a line
(evil-define-motion vertigo-evil-down (count)
  "Evil vertigo motion. Count has no effect."
  (vertigo-jump-down)
  (forward-line))

If anyone would like these, I could add evil as an optional dependency and add them directly. Alternatively, if you want avy line jumping motions, I’d highly recommend using evil-easymotion instead.

Configuration

No keys are bound by default. The following commands are provided:

vertigo-jump-up and vertigo-jump-down will jump an actual number of lines.

vertigo-visible-jump-up and vertigo-visible-jump-down will jump a number of visible lines. For example, they will not jump into a folded org heading.

vertigo-visual-jump-up and vertigo-visual-jump-down will jump a number of visual lines (as in visual-line-mode). They will not jump into invisible text and will consider a soft-wrapped line to count as the number of visual lines it takes up.

For non-QWERTY users, vertigo-home-row can be changed:

(setq vertigo-home-row '(?a ?r ?s ?t ?d ?h ?n ?e ?i ?o))

Since it is inefficient to use these commands to jump one or two lines, vertigo can take a second key as input for some keys. For example, pressing aa would jump 11 lines and pressing a; would jump 10. To control the max home row key where 2 keys are input, vertigo-cut-off can be set. It defaults to 3, meaning that 39 lines can be jumped at maximum. Pressing d(key2) will jump 30 something lines, but pressing f will immediately jump 4 lines.

vertigo-max-digits can be configured to change the maximum number of digits that can be input. It defaults to two. If you want to use vertigo with commands where a count could be 100 or more, you can increase the value. vertigo-cut-off only has an effect when vertigo-max-digits is two.

Regardless of the values of vertigo-cut-off and vertigo-max-digits, pressing a capital letter from vertigo-home-row will immediately end the number (e.g. pressing A by default will correspond to the number 1).