I have started using vim a while back, and I’ve been using the w, e, b and (my favorite) f/t motions quite extensively lately to move within the row efficiently.

To learn those motions, and break out my annoying habit of scrolling up and down the page using jjjjj and kkkkk. I’ve used the vim plugin takac/vim-hardtime. This plugin did allow me to get more confident with horizontal navigation, but one pain point still remains vertical navigation.

Known vertical motions

I always had the justinmk/vim-sneak plugin in my config; it’s a great motion to precisely move vertically and combined with <number>j/k, I can pretty much express all of the vertical movement I want.
While I do use those motions quite often, and I cannot live without them, they didn’t always felt as natural as the f/t motions.

What I don’t like

  • 👎 I find vim-sneak too heavy for line-wise operation, so I use <operator><number>j/k.
  • 👎 I find reading the number value of <number>j/k too complicated and slow.

What I like

  • 👍 I find the vim-sneak label indicator it’s very intuitive (let g:sneak#label = 1).
  • 👍 I find the <number>j/k very adapted for line-wise operation (e.g., delete 4 lines).

My new favorite motions

I’ve discovered a so-called edgemotion motion while watching this video: youtube: vim-mode-plus: The most ambitious vim emulator in the world. (Also learn a ton of other stuff).

The vim version of this plugin is made by haya14busa, vim-edgemotion.

edgemotion demo

I have fixed one misbehavior in the interpretation; support for a preceding count number, and added support a feature to display counts numbers on the number gutter).

With those two modifications to the original plugin, I have now the best of both world:

  • 👍 I can still use vim-sneak for precise jumps, and <number>j/k for short line operation.
    (short as I don’t have to look the line number in the gutter, usually for 2-4 line operation).
  • 👍 For longer line operation, I rely on the fact that my code should be well indented/separated, and use the vim-edgemotion, when needed, I look at the count number displayed in the line gutter.

To conclude, edgemotion helps for distinct line-wise operation, as it’s easy to visualize the vertical edge of a code block. It also helps for ‘longer’ line jumps as the number of edgemotion jump is usually be a single-digit instead of two when using the regular <number>j/k motion.

Here is my fork with the discussed changes Drakirus/vim-edgemotion