tags:

views:

141

answers:

3

Hi all,

I was wondering if there's a way to open multiples files with Vim, but each file on a specific line number. I explain :

I often use the syntax : vim my/way/too/far/file +120 in order to edit this file at line 120 because gcc told me too :)

Now what i'm looking for is a way to do this for multiples files at the same time!

Of course, vim file1 +xx file2 +xx ... won't work (the + option only affect first file ... don't ask me why)

So if anyone know a way to fix this? I didn't found it in the manpage...

By the way, sometimes, file1 maybe the same file as file2 ...

+5  A: 

Here's a way : vim +6 file1 +"sp +3 file2". Change sp to tabnew if you prefer tabs.

But it would be really useful only if someone could make a script with it...

Pikrass
that does work! great, now i just have to figure how to use xargs to go from a list of file1 +10file2 +14...to vim +10 file1 +"tabnew +14 file2" +"tabnew +...(yes i prefere tabnew :)i'll post my cmd line if i have enought faith to write it ;)thx!
claferri
In fact, the bad thing is that this solution doesn't allow more than something like 10 files max at the same time.I'm using a command to get filenames and line and using xargs to pass them to vim.I'd like to be able to launch as much file as I want, i'm disappointed that vim can't handle more than 10 files to open at the same time ...
claferri
Maybe you could use a `for` in the ViM command, whith a list of filenames and another for the cursor positions.
Pikrass
+1  A: 

Another option would be using a script like utl, automatically creating a file full of hyperlinks to the file / line numbers based on the output of gcc (this should be trivial with sed).

A link would be formatted like this with utl: <url:error.c#line=10>

EDIT: linked to a more appropriate vim linking script.

Justin Smith
Neil's suggestion is a better version of this.
Justin Smith
+3  A: 

vim can read your gcc output and create a quickfix list that allows you to navigate easily though all the errors in your code. You can read an existing error file using vim -q or if your project uses a Makefile then you can use the :make command to execute make from within vim and capture its output.

Neil