Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Vim-vertical: Get around 2-dimensionally in vim (github.com/rbong)
102 points by rbongers on May 15, 2016 | hide | past | favorite | 39 comments


I learned vim about two years ago and have been using it ever since, and at the time I learned it I learned all the neat combos for moving your cursor ("w", "5w", "b", "^", "$", and many other actually complicated ones besides).

As clever as these motions are though, easymotion simply blows them out of the water and there's no reason to use them. With easy motion it only takes as long as it takes your eye to move to where you want to move and you're there...you really can't beat that.

In some cases of course easymotion isn't enough because the place to which you need to move isn't on screen. So far all files I edit are short enough that I can scan the whole thing relatively easily by just holding down "J" or "K" (which I have mapped to "10j" and "10k")


vim-sneak[1] is a less bling-bling alternative to easymotion. I originally wrote it to address the sub-optimal valley between Vim's built-in near-distance (f, t, ...) and long-distance (/) motions. It also tries to avoid the hesitation that easymotion introduces, by avoiding the need to select a label if the first match is correct.

[1] https://github.com/justinmk/vim-sneak


For what it's worth, I use vim-sneak and I like it tremendously. Thank you.


There is a Spacemacs layer with nearly the same functionality called evil-snipe which binds s and S.


Isn't it more accurate to say there's an elisp package called evil-snipe which does this? The spacemacs layer didn't write the functionality, it's one example of how to configure it.


Yes, it sure is. But in the context we're talking about: Vim and Vim users, I think mentioning it as a Spacemacs layer is an acceptable offense.


I remember trying out easymotion and disliking its flashy UI effects. This plugin seems cool, thanks for sharing (and creating it).


Just installed, love it. Thanks!


That J and K mappings sound like a pretty good idea actually... I'd been using <leader>j for 10j.


Joining lines and looKing up definitions is far too useful for me.


I'm trying out <leader>j for join for now, seems handy so far. I'm liking being able to hit the J for 10j several times in a row fast. I don't think I join often enough to mind it being 2 sequential keys instead of a combo.


Just installed it and from my immediate first impression this is gonna be a time/strokesaver. Good on you!


I find vim-sneak works well for me, as it tries to extend "vim's natural language" so to speak.

https://github.com/justinmk/vim-sneak

Otherwise relative numbers and gj/ gk work well enough for me when it comes to moving vertically to a position I can see on the screen.


Has the author heard of gj and gk?


It's not really the same though, gj and gk move the cursor by displayed lines instead of real lines.

Op's plugin is like transposing the buffer like a matrix, and then using normal word motions on the line that was a column.


My immediate first thought. Although, the Vim is large and our brains so very small.


It's worth reading the description again in that case, and following the examples in the screenshots. It's not doing the same thing.


If I understand correctly, I can gj down a few times and get the same general effect, without having to install something.

For me there's a tension between a growing number of very specific features and my ability to remember them all. These days I opt for minimal vim addons, as there's usually a good enough way to get something done by default.

But for people who need exactly this sort of thing, this thing is exactly the sort of thing they'll like.


Yeah, gj is similar in the same way that you can press l a few times instead of e. (I've mapped j to do the same thing as gj anyway as I want to navigate the physical screen, not honour lines as indivisible entities).


Many editors have an Easy Motion plugin:

https://code.tutsplus.com/tutorials/vim-essential-plugin-eas...

I believe Sublime, Emacs, and Atom all have one.


Yep, and all of them have "blind spots" or lack attention to subtle details, because the authors didn't use Vim for very long, if at all.


Try'na make your own then?



His is the best of the all.

https://github.com/justinmk/vim-sneak


tldr;

> Many times, I have been at the end of a line after editing it and needed to go to a nearby long line.


I find this better solved by vim-columnmove:

https://github.com/machakann/vim-columnmove


i'm happy with :relativenumber and classic motions + marks (eg ma + 'a)


How long does it take to learn the Vim way of navigating so that you do not have to think when doing it, like the fingers move by themselves ?

And how much time do you save, compared to placing the cursor using the mouse?


It's not really a matter of saving time, but eliminating friction (context-switches). Editing is a chore, and fiddling with text while taking notes, or debugging, or thinking about a problem, has a cost.

It's also quite alarming to reach a level of proficiency where you can make non-trivial edits without looking at what you're editing, and know that the edits are correct. Again, this avoids context-switches.

That's why Vim is so focused on precision ("do exactly this") rather than DWIM ("Do What I Mean [usually]": the emacs/IDE approach).

Certainly whether the ramp-up cost is worth the "payoff" is debatable, but for me, editing text became so irritating that my initial experiments with Vim were driven from pure exhaustion after years of blub-craft.


That point about "do exactly this" vs DWIM is interesting. As an evil user, I didn't think of it that way, but I can definitely see where this is true.


In my experience, arbitrary movement when what you move to is on the screen is actually faster if you use a mouse. It's unconventional, but I use a mouse for such movements for that reason (vim has excellent mouse support, even its TUI version).

In vim some operations require a movement, where vim's movement has an advantage over using the mouse. For example, dt. deletes until the next period, or ci( which deletes the text inside parentheses and then enters insert mode.


You can still use the mouse for navigating. You should also keep in mind that one of the big advantages of vim is not just the ability to navigate quicker, but to combine quick movements with other operations -- for example, deleting text until a specified character, or copying text inside parentheses (from anywhere inside the parentheses).


Took me about 2-3 weeks to be productive in Vim. First week was pretty painful (though vimtutor helped a lot). If you are going to work your whole life with computers it's definitely worth it (and it's not only about time saved though that's a big one).


I'm pretty happy with just

:set nu

:20 # go to line 20


Some people even like:

:set rnu


alright, this solves my problem much better


or

G20


Thanks for the other suggestions for vertical movement. I think /? and vim-vertical is all I need.


First of all, I want to say thanks to both authors Vim-vertical and vim-sneak for trying to do something useful for Vim community.

Therefore, I think that it's quite a bad idea to use any of this plugins. The reason is that the most powerful Vim's concept is text-object and such shortcuts ruining muscle memory and mixing core technology understanding.

IMHO easy-motion gives excellent text-object visualization which helps me to understand text structure better.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: