I work almost exclusively in the terminal, and very often I need to view files that appear in error stacktraces. A very common format is /some/file:99
, where 99 is the line number. I'd like to be able to copy that line, and open goto that line easily in vim.
What I'm looking for is the ability to do :e /some/file:99
, and vim automatically opens that file at line 99. Does something like this exist? If not, is it possible to write a plugin for it?
Vim can display line numbers in the left margin: Press ESC key. At the : prompt type the following command to run on line numbers: set number. To turn off line numbering, type the following command at the : prompt set nonumber.
Pressing ctrl-g will reveal the filename, current line, the line count, your current position as a percentage, and your cursor's current column number.
The edit command can take options, so try this:
:e +99 /some/file
Just found this link:
http://vim.runpaint.org/basics/opening-files/
You may prefix the filename with +linenumber to instruct Vim to jump to the given line after opening. For example, vim +7 todo.list or :e +100 treatise.txt. If you omit linenumber, i.e. you prefix the filename with +, Vim will jump to the end of the file.
If you can redirect /some/file:99
to a file then you can jump to /some/file
at line 99 by just pressing gF
when you cursor is on file's name.
This plugin was designed with this specific purpose in mind: file:line
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With