Open Vim to a specific line


Sometimes I find it useful to open a file in Vim from my terminal to a specific line. Perhaps I know the line number in question because a colleague was referencing it. Or maybe I saw it in a stack trace. Vim can do this out of the box:

  • vim myfile.js +10 – Opens myfile.js, jumps to line 10
  • vim +10 myfile.js – Same! Argument order doesn’t matter

This alone can be a useful trick. It works everywhere and requires no plugins. Yet it is still one keystroke more than just calling :10 after the file opens to jump to the line.

If you’ve ever read a stack trace, you’ve probably seen file paths and line numbers written like this:


You may even see a column position amended like this:


Several solutions exist for opening a file to a specific line and column number when written in these formats. The one I use is called Vim-fetch and it supports both of these formats, and many more. Here’s a gif showing both methods, with and without plugin, in action:

How useful was this tip?

Average rating 3.4 / 5. Vote count: 262

No votes so far! Be the first to rate this tip.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Written by

Colin Bartlett

105 Posts

Vim enthusiast and software developer for more than 20 years.
View all posts