Search code examples
vimrangelinegoto

Vim: long range movements


I've been using vim for a day so far, so I'm still learning the basic stuff and thinking on how to do such movement to go here and there, and so on.

For long screen movements, I've found the nG command (goto line n) to be quite handy, yet I was wondering if you (vimmers) usually use it, or if there are more efficient ways to do long travels with less inputs.

Also, I've learnt that you could enable relative line numbers to move easier with nj and nk. Do you actually use it instead of nG (if you happen to use it)?


Solution

  • if you know the exact line number you want to go, the nG (the n is line number) would be the best way.

    If not, there are many ways to do "long range" motion:

    • ctrl-d/u
    • /pattern
    • * or #
    • ) (sentence)
    • } (paragraph)
    • ] command :h ]
    • x% like 30% go to the 30% position of the content
    • H, L, M moves cursor on same screen (H:1st line, M:Middle, L:lastline)
    • ....

    If the "long range" was still on the same screen, there is a nice plugin EasyMotion, you would like it.