atom/vim-mode — pull request #77 by dougblack (2014-02-27 21:50:19+00:00)
Title: H, L, and M

Adds support for vim's `H`, `L`, and `M` keybindings.

![hlm1](https://f.cloud.github.com/assets/942395/2288375/129b10b4-9ff9-11e3-82fe-5a1eb88ace45.gif)

It seems atom currently has a built in `scrolloff` value. vim defines `scrolloff` as:

> Minimal number of screen lines to keep above and below the cursor.

This means that moving the cursor to the first visible line of an `EditorView` will actually *change the first visible line to the line two lines previous*.

Considering atom's built in `scrolloff` value, I copied Vim's behavior for `H` and `L` when used with scrolloff--pressing `H` jumps to the first visible line that *will not cause first visible line to change*. In this case that is the third line from the top.

When at the actual beginning or end of a file, Vim lets `H` and `L` jump to the first or last lines of the file, respectively. This pull mimics that behavior as well.

Without a way to query to query the scrolloff value, I had to hard code the offsets. Once `scrolloff` becomes query-able, this should be updated to dynamically evaluate the offsets.

I tried adding tests but couldn't find how to make it work because `H`, `L`, and `M` depend on the current set of visible lines which I didn't know how to mock out in a spec. Advice here would be appreciated.