At my workplace using my current compiler I have a vim plugin enabled. The only thing that I am uncomfortable with vim is vertical line navigation and I wanted to know how some of the vim gurus overcome this situation.My typical work scenario would be a situation such as this:

Suppose I am on a page displaying lines 145 till 220. My cursor is on line 150 and I would like to go to line 183. To do so I would type 183G.

I wanted to know if there was an easier way to accomplish that(because sometimes a line number might be in the thousands). What techniques do people here use for vertical navigation ? In this case it seems to be easier if I just grabbed the mouse and moved there instead. Any advice on this situation would be helpful.


1 Answer 1


There are different way to move vertically in Vim, they all depends on what you want to do:

  • In normal mode { and } allows to move to the beginning or the end of a paragraph (i.e. a block of lines without blank or empty line)
  • In normal mode Shift-h, Shift-m and Shift-l allows you to go the the top, the middle and the bottom of the screen.
  • You can use /pattern to search for the next occurrence of a desired pattern and use ?pattern to make a backward search. Use n and Shift-N to repeat the search in the same way or in the contrary way. To use this method you might want to add set incsearch to your .vimrc to see the pattern matched as you type it.
  • Another solution is to use marks: if you know a place where you regularly need to go in your file you can set a mark at this line with m-[X] where [X] is one of the letters of the alphabet. You can then use '-[X] anywhere in the file to go back to this line.
  • Finally if you are editing source code files you can use a tag system (like exuberant-ctags ) combined with the taglist plugin to navigate your code.

Use the corresponding method depending on how "fast" you need to navigate.

  • 1
    Point 3 is very similar to Bram's document, moolenaar.net/habits.html (see part 1 about file navigation). There is the mechanics of file navigation and then there is the mindset of asking our self, "what am I navigating to". You do provide a very comprehensive list of approaches. Apr 15, 2016 at 14:27

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.