Pierre Champion

PhD Student

Fast Vertical Movement Inside Vim

Posted at — Sep 22, 2019

Introduction

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

What I like

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:

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 pchampio/vim-edgemotion