I'm aware of many ways of jumping around a text file in Vim.

  • Ctrl-f/b/u/d
  • <count>G
  • <count>%
  • marks
  • {,}

And several other ways.

How can I jump around efficiently in long file? Please include a bit of "user experience" reasoning.

Please limit suggestions or techniques for vertical navigation only.

  • I've removed the end bits calling for opinion, which is off-topic here. I've also simplified the description of motions in the question and formatted them.
    – D. Ben Knoble
    Commented Dec 8, 2022 at 17:34

3 Answers 3


You can use:

  • [m and ]m to navigate from one method to the next
  • [[ and ]] to navigate from one class to the next

You can also fold the entire file with zM to see only the top objects (class and function) and then zo to see the methods of the selected class and finally zR to unfold all the folds.

You can use plugin that show the structure of your code like: tagbar


Tags and other related "jump here" (e.g., :help include-search, gf, gd, *) commands are great, when set up correctly. Searching with /,? is similarly fast. Both give you great control and precision to reach related code.

The :grep, :vimgrep, :make, etc., commands all populate the quickfix list (but can be made to populate the location list). This list can be navigated with a few commands, or browsed in a window, to quickly jump to "interesting" parts of the code.

Both the quickfix/location lists and tags may involve traversing more than the current file, but in practice that's well worth it. In many cases you can restrict to the current file.

I also recommending learning more about ranges; inputting a range with no command jumps to the first line in that range. Search and marks work, too, and using : is occasionally faster (typically when you already want to operate on that range and know the Ex command to do it).


The one (visible) difference between the BSD and Linux coding styles is that the BSD coding style puts the function name into the first column:

getlastch(const char *arg, size_t len)
        return (len ? arg[len - 1] : -1);

In vi(1) you can then navigate to this with /^getlastch or probably even already just /^getl. For navigation between files, ctags are the traditional solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.