Vim

Vim: vim-easymotion

vim-easymotion extends the regular Vim motions by highlighting target locations in your Vim window (or windows, more on that in a bit) using colored characters that are overlayed on your work. Once you select a target location the cursor is moved and the overlayed characters are removed.

It’s difficult to convey in words just how useful this is.

By default vim-easymotion is invoked by <leader><leader> followed by a motion. My leader is , so I invoke vim-easymotion by entering ,, followed by a motion (w, b, j, k, etc.).

For example, if I wanted to jump to a word that is say, nine, words ahead I could enter w nine times. That’s a little inefficient. I could guess how many words ahead I’m looking to jump and enter 7w and then hit w a couple of times until I get there. Reasonably efficient and a decent approach.

The vim-easymotion way would be to enter ,,w after which the start of each word would be higlighted by a letter and then press the letter corresponding to where I want to jump.

In terms of characters entered this one is a wash, but I do find it takes less thinking to land where I want to be. But, there is the added benefit that all words for the remainder of the page will be highlighted and you can jump to them.

Let’s look at another motion, this time line movement. I could roughly guess how many lines I want to move up in the file and enter nnk and then use j or k as needed to land at my target. Honestly, this works well most of the time and if you want to get more accurate you can always use relativelinenumber.

The vim-easymotion way would be to enter ,,k after which the start of each line would be higlighted by a letter and then press the letter corresponding to where I want to jump.

This one is also a wash, about the same number of characters to enter, but arguably less thinking required.

These motion additions are useful, but if that all there was to vim-easymotion you would not make the effort. The real benefit comes when you start using some of the plugin functions.

Plugin Functions

vim-easymotion has a number of plugin functions that can be mapped and you can read about in the documentation. There are only two that I use. I find them incredibly useful and I’m sure that if I explored deeper there woould be even more wondeful surprises, but for now I’m quite happy with just these two.

nmap <leader>s <Plug>(easymotion-overwin-f2)

So, I enter ,s and I am prompted for the 2 character sequence that I am targetting. This works across windows!!! Yes, that’s right, I can target any part of any window in my Vim layout. You enter the 2 characters, press enter, and select your target key. You target the exact location on your desired line. It is an incredibly efficient way to navigate your screen real estate.

The mnemonic I use for this is s for seek.

nmap <leader>f <Plug>(easymotion-bd-f)

This one searches for a single character but in both directions from the cursor location (bd is bidirectional).

And that’s really it for my vim-easymoiton usage. There is a lot more availableif you want to dig into the documentation, but you might find that this is sufficient for your needs too.

Resources

:help easymotion

Source: https://github.com/easymotion/vim-easymotion

Tools

Web

Languages

Data