syntax for filename + line number

7 views
Skip to first unread message

mobi phil

unread,
Oct 23, 2009, 12:24:49 PM10/23/09
to vim...@googlegroups.com
Hello,

lot of programs (gdb, gcc) have as output information about file and
line in form of

<filename>:<number>

I wonder if it would not be clever to make vim accept such a syntax
for opening file.
Eventually with a flag that would switch on/off this syntax.


This would be interesting both when opening a file:

vim <filename>:<number>

or internally

:new/edit/split <filename>:<number>

I know that you can specify in both forms the line number separatelly
with +<linenum>, but
the proposed form is much more handy if you copy paste info from
commands like the mentioned
ones


thanks for your attennion,
mobi phil

being mobile, but including technology
http://mobiphil.com

Craig Barkhouse

unread,
Oct 23, 2009, 2:30:34 PM10/23/09
to vim...@googlegroups.com
mobi phil said:
> This would be interesting both when opening a file:
>
> vim <filename>:<number>
>
> or internally
>
> :new/edit/split <filename>:<number>

I don't think adding this syntax is a good idea, as it conflicts with opening named data streams on Windows. It also could conflict with drive letter syntax if <filename> is a single alpha character.

Craig

mobi phil

unread,
Oct 23, 2009, 2:38:09 PM10/23/09
to vim...@googlegroups.com
> I don't think adding this syntax is a good idea, as it conflicts with opening named data streams on Windows.  It also could conflict with drive letter syntax if <filename> is a single alpha character.

I am affraid everything what is in IT is conflicting with Windows :) .
That should not stop IT to evolve.
There are tons of settings that differ from **x to windows. Some of
the behaviour is automatically
changed some are switchid with variables. The same can happen with this one


rgrds,

Ingo Karkat

unread,
Oct 23, 2009, 2:47:02 PM10/23/09
to vim...@googlegroups.com
On 23-Oct-09 18:24, mobi phil wrote:
> Hello,
>
> lot of programs (gdb, gcc) have as output information about file and
> line in form of
>
> <filename>:<number>
>
> I wonder if it would not be clever to make vim accept such a syntax
> for opening file.
> Eventually with a flag that would switch on/off this syntax.
>
>
> This would be interesting both when opening a file:
>
> vim <filename>:<number>
>
> or internally
>
> :new/edit/split <filename>:<number>
>
> I know that you can specify in both forms the line number separatelly
> with +<linenum>, but
> the proposed form is much more handy if you copy paste info from
> commands like the mentioned
> ones

This can be achieved via an autocmd; in fact, the file-line plugin provides this
functionality:
http://www.vim.org/scripts/script.php?script_id=2184

-- cheers, ingo
--
-- Ingo Karkat -- /^-- /^-- /^-- /^-- /^-- /^-- http://ingo-karkat.de/ --
-- http://vim.sourceforge.net/account/profile.php?user_id=9713 --

Tony Mechelynck

unread,
Nov 23, 2009, 9:43:29 PM11/23/09
to vim...@googlegroups.com, mobi phil

Vim has already two built-in mechanisms of this kind:

1) for a one-time opening of a file at a given position, see ":help +cmd"

:e +123 foobar.txt
open foobar.txt at line 123

:e + foobar.txt
open foobar.txt at end

:e +/pattern foobar.txt
open foobar.txt at the first line matching /pattern/

:e +/pattern\ with\ spaces foobar.txt
spaces must be backslash-escaped

etc.

2) if your program generates a number of such file-locations, like grep
does, or like a make run with a number of errors and warnings: see
:help quickfix.txt
:help :compiler
:help 'errorformat'
etc.


Best regards,
Tony.
--
Parker's Law:
Beauty is only skin deep, but ugly goes clean to the bone.

mobi phil

unread,
Nov 25, 2009, 10:44:56 AM11/25/09
to Tony Mechelynck, vim...@googlegroups.com
Hello,

Thanks for describing the 2 ways. I am not happy if I would disappoint
you for writing that down, but I was aware about those.
What I was a bit annoyed, is that a format that is output of several
commands used everyday by most of us, is not accepted as "standard"
command line. I have created for myself a wrapper that converts
file:line into file +line.

So my wrapper is wrvim and
wrvim file:line
is the same as
wrvim file +line


--
rgrds,

Ingo Karkat

unread,
Nov 25, 2009, 10:51:01 AM11/25/09
to vim...@googlegroups.com
On 25-Nov-09 16:44, mobi phil wrote:
> Hello,
>
> Thanks for describing the 2 ways. I am not happy if I would disappoint
> you for writing that down, but I was aware about those.
> What I was a bit annoyed, is that a format that is output of several
> commands used everyday by most of us, is not accepted as "standard"
> command line. I have created for myself a wrapper that converts
> file:line into file +line.
>
> So my wrapper is wrvim and
> wrvim file:line
> is the same as
> wrvim file +line

Why don't you use the file-line.vim plugin? I mentioned it a month ago in
exactly the current thread:
http://groups.google.com/group/vim_dev/msg/722aefe8494c3a44

-- cheers, ingo

mobi phil

unread,
Nov 26, 2009, 3:51:39 PM11/26/09
to vim...@googlegroups.com
> Why don't you use the file-line.vim plugin? I mentioned it a month ago in
> exactly the current thread:
>     http://groups.google.com/group/vim_dev/msg/722aefe8494c3a44

when I tried that plugin last time, I must have made some mistake when
installing it, did not work. As you insisted, I tried it again, and:

IT WORKS :), so thanks.

However my wrvim still makes sense as it always knows what to open, for example:

(alias vi=wrvim)
->vi my life



Thanks again, Ingo, Tony, Craig
Reply all
Reply to author
Forward
0 new messages