Skip to content

daantjie/vertigo.el

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

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). However, especially since the various relative line number packages for emacs don’t work that well currently (e.g. potential performance hit), avy is probably a more suitable choice. Avy’s overlays could be seen as temporary “relative line numbers” since they also provide a visual cue for selecting the line you want to jump to. One could also temporarily enable relative line numbering just before a vertigo command, but avy’s overlays are probably even more convenient given they correspond to the exact keys you need to press, and no translation from numbers into keys is required. That said, I’m used to and like the correspondence between the home row and line numbers introduced in the vim vertigo plugin. I’ll maintain this package in the hopes that relative line numbering eventually becomes more viable in emacs.

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.

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.

About

Jump lines using the home row

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Emacs Lisp 100.0%