vim - open file and goto line number using ::
up vote
20
down vote
favorite
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.
vim gvim
add a comment |
up vote
20
down vote
favorite
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.
vim gvim
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
add a comment |
up vote
20
down vote
favorite
up vote
20
down vote
favorite
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.
vim gvim
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.
vim gvim
vim gvim
asked Oct 5 '12 at 7:14
Sardathrion
2,43542249
2,43542249
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
add a comment |
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
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
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
add a comment |
4 Answers
4
active
oldest
votes
up vote
14
down vote
accepted
You can use the file:line plugin available here, which does exactly what you want...
1
It sure does and with the added bonus that you can use vundle to install it.
– Sardathrion
Jun 25 '15 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 '15 at 9:06
add a comment |
up vote
9
down vote
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##*:}; }
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
add a comment |
up vote
2
down vote
With Vundle.vim, add this to your .vimrc
:
Plugin 'bogado/file-line'
@Sardathrion: Which issues do you have?
– Dorian
Oct 14 '16 at 0:13
I moved to neovim and there are lots of issues that mark other modules (or whatever neovim calls them) as incompatible.
– Sardathrion
Oct 14 '16 at 6:50
add a comment |
up vote
0
down vote
You can also use such alias:
alias gd 'set number=`echo !:1 | perl -pe "s/([0-9]*:)?(.+)[,:]([0-9]+).*/3/"`; set file=`echo !:1 | perl -pe "s/([0-9]*:)?(.+)[,:]([0-9]+).*/2/"`; eval "if ($number == $file) then \
gvim $file \
else \
gvim $file +$number \
endif"'
New contributor
add a comment |
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
14
down vote
accepted
You can use the file:line plugin available here, which does exactly what you want...
1
It sure does and with the added bonus that you can use vundle to install it.
– Sardathrion
Jun 25 '15 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 '15 at 9:06
add a comment |
up vote
14
down vote
accepted
You can use the file:line plugin available here, which does exactly what you want...
1
It sure does and with the added bonus that you can use vundle to install it.
– Sardathrion
Jun 25 '15 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 '15 at 9:06
add a comment |
up vote
14
down vote
accepted
up vote
14
down vote
accepted
You can use the file:line plugin available here, which does exactly what you want...
You can use the file:line plugin available here, which does exactly what you want...
answered Jun 6 '14 at 16:59
mmigdol
25623
25623
1
It sure does and with the added bonus that you can use vundle to install it.
– Sardathrion
Jun 25 '15 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 '15 at 9:06
add a comment |
1
It sure does and with the added bonus that you can use vundle to install it.
– Sardathrion
Jun 25 '15 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 '15 at 9:06
1
1
It sure does and with the added bonus that you can use vundle to install it.
– Sardathrion
Jun 25 '15 at 6:53
It sure does and with the added bonus that you can use vundle to install it.
– Sardathrion
Jun 25 '15 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 '15 at 9:06
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 '15 at 9:06
add a comment |
up vote
9
down vote
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##*:}; }
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
add a comment |
up vote
9
down vote
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##*:}; }
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
add a comment |
up vote
9
down vote
up vote
9
down vote
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##*:}; }
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##*:}; }
edited Oct 5 '12 at 7:48
answered Oct 5 '12 at 7:38
Julian
66944
66944
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
add a comment |
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
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
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
2
You can edit a +11 file by saying vim ./+11
– Julian
Oct 5 '12 at 7:47
You can edit a +11 file by saying vim ./+11
– Julian
Oct 5 '12 at 7:47
add a comment |
up vote
2
down vote
With Vundle.vim, add this to your .vimrc
:
Plugin 'bogado/file-line'
@Sardathrion: Which issues do you have?
– Dorian
Oct 14 '16 at 0:13
I moved to neovim and there are lots of issues that mark other modules (or whatever neovim calls them) as incompatible.
– Sardathrion
Oct 14 '16 at 6:50
add a comment |
up vote
2
down vote
With Vundle.vim, add this to your .vimrc
:
Plugin 'bogado/file-line'
@Sardathrion: Which issues do you have?
– Dorian
Oct 14 '16 at 0:13
I moved to neovim and there are lots of issues that mark other modules (or whatever neovim calls them) as incompatible.
– Sardathrion
Oct 14 '16 at 6:50
add a comment |
up vote
2
down vote
up vote
2
down vote
With Vundle.vim, add this to your .vimrc
:
Plugin 'bogado/file-line'
With Vundle.vim, add this to your .vimrc
:
Plugin 'bogado/file-line'
edited Jan 17 at 10:17
answered Oct 12 '16 at 15:56
Dorian
1214
1214
@Sardathrion: Which issues do you have?
– Dorian
Oct 14 '16 at 0:13
I moved to neovim and there are lots of issues that mark other modules (or whatever neovim calls them) as incompatible.
– Sardathrion
Oct 14 '16 at 6:50
add a comment |
@Sardathrion: Which issues do you have?
– Dorian
Oct 14 '16 at 0:13
I moved to neovim and there are lots of issues that mark other modules (or whatever neovim calls them) as incompatible.
– Sardathrion
Oct 14 '16 at 6:50
@Sardathrion: Which issues do you have?
– Dorian
Oct 14 '16 at 0:13
@Sardathrion: Which issues do you have?
– Dorian
Oct 14 '16 at 0:13
I moved to neovim and there are lots of issues that mark other modules (or whatever neovim calls them) as incompatible.
– Sardathrion
Oct 14 '16 at 6:50
I moved to neovim and there are lots of issues that mark other modules (or whatever neovim calls them) as incompatible.
– Sardathrion
Oct 14 '16 at 6:50
add a comment |
up vote
0
down vote
You can also use such alias:
alias gd 'set number=`echo !:1 | perl -pe "s/([0-9]*:)?(.+)[,:]([0-9]+).*/3/"`; set file=`echo !:1 | perl -pe "s/([0-9]*:)?(.+)[,:]([0-9]+).*/2/"`; eval "if ($number == $file) then \
gvim $file \
else \
gvim $file +$number \
endif"'
New contributor
add a comment |
up vote
0
down vote
You can also use such alias:
alias gd 'set number=`echo !:1 | perl -pe "s/([0-9]*:)?(.+)[,:]([0-9]+).*/3/"`; set file=`echo !:1 | perl -pe "s/([0-9]*:)?(.+)[,:]([0-9]+).*/2/"`; eval "if ($number == $file) then \
gvim $file \
else \
gvim $file +$number \
endif"'
New contributor
add a comment |
up vote
0
down vote
up vote
0
down vote
You can also use such alias:
alias gd 'set number=`echo !:1 | perl -pe "s/([0-9]*:)?(.+)[,:]([0-9]+).*/3/"`; set file=`echo !:1 | perl -pe "s/([0-9]*:)?(.+)[,:]([0-9]+).*/2/"`; eval "if ($number == $file) then \
gvim $file \
else \
gvim $file +$number \
endif"'
New contributor
You can also use such alias:
alias gd 'set number=`echo !:1 | perl -pe "s/([0-9]*:)?(.+)[,:]([0-9]+).*/3/"`; set file=`echo !:1 | perl -pe "s/([0-9]*:)?(.+)[,:]([0-9]+).*/2/"`; eval "if ($number == $file) then \
gvim $file \
else \
gvim $file +$number \
endif"'
New contributor
New contributor
answered Dec 3 at 8:05
user2683458
1
1
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f49996%2fvim-open-file-and-goto-line-number-using-filenameline-nbr%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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