Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Several tools such as grep, py.test, etc ... use the pattern <FileName>:<line number>: to point to errors. For example:

; grep -Hn Common setup.cfg
setup.cfg:11:    Common

How can I modify vim and gvim so that I can invoke them like so:

gvim setup.cfg:11:

instead of

gvim setup.cfg +11

I know that I can write a small shell script that would parse things but I wonder if there is an easier way.

share|improve this question
2  
This isn't exactly analogous, but vim does have a feature to load the output from grep or (for example) compiler errors from make, and navigate between them. See :help quickfix for more info. –  Random832 Oct 5 '12 at 12:48

2 Answers 2

up vote 6 down vote accepted

You can use the file:line plugin available here, which does exactly what you want...

share|improve this answer
    
It sure does and with the added bonus that you can use vundle to install it. –  Sardathrion Jun 25 at 6:53
    
The references file-line plugin has some issues, including brokeness when tab pages are in use. vim-fetch does what file-line does, but better. –  Lekensteyn Jul 16 at 9:06

There isn't a way, and I think a script is the only way. The reason being, what if you had a file called setup.cfg:11 and wanted to edit it?

Here is a quick script that does what you want as a oneliner...

editline() { vim ${1%%:*} +${1##*:}; }
share|improve this answer
    
Sorry this is not accurate: What if you had a file called +11? You can, of course, use -- for that. –  Sardathrion Oct 5 '12 at 7:44
2  
You can edit a +11 file by saying vim ./+11 –  Julian Oct 5 '12 at 7:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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