Have every file open into a new tab with gvim?

1,390 views
Skip to first unread message

Dick Moores

unread,
Aug 16, 2008, 12:41:49 PM8/16/08
to vim...@googlegroups.com
How can I configure gvim to have every file I open, open into a new
tab in the same instance of gvim, not a new instance?

Thanks,

Dick Moores

Dave Land

unread,
Aug 16, 2008, 3:12:59 PM8/16/08
to vim...@googlegroups.com
On Aug 16, 2008, at 9:41 AM, Dick Moores wrote:

> How can I configure gvim to have every file I open, open into a new
> tab in the same instance of gvim, not a new instance?

If you're using gvim from the command-line, this should help:

:help -p

This does exactly what you want.

If I'm on the command line (I'm on Mac OS X, so YMMV), if I issue the
following command:

gvim -p *.jsp

It will open as many JSP files as are in the current directory, with
the first 10 files in separate tabs, and the remaining files open as
buffers without tabs.

Does anyone know how to make gvim open more than 10 tabs at a time?

Dave

Tony Mechelynck

unread,
Aug 16, 2008, 3:26:09 PM8/16/08
to vim...@googlegroups.com
On 16/08/08 21:12, Dave Land wrote:
[...]

> Does anyone know how to make gvim open more than 10 tabs at a time?
>
> Dave

see ":help 'tabpagemax'"


Best regards,
Tony.
--
The only way to get rid of a temptation is to yield to it.
-- Oscar Wilde

Dick Moores

unread,
Aug 16, 2008, 5:28:09 PM8/16/08
to vim...@googlegroups.com
At 12:12 PM 8/16/2008, Dave Land wrote:

>On Aug 16, 2008, at 9:41 AM, Dick Moores wrote:
>
> > How can I configure gvim to have every file I open, open into a new
> > tab in the same instance of gvim, not a new instance?
>
>If you're using gvim from the command-line, this should help:
>
>:help -p
>
>This does exactly what you want.
>
>If I'm on the command line (I'm on Mac OS X, so YMMV), if I issue the
>following command:
>
>gvim -p *.jsp

OK, I just did a

gvim -p *.vim

I didn't SEE anything happen--no files opening, each in their own
tabs. But when I checked the Buffers menu, I saw that 19 had been
opened for .vim files. But where are the tabs? I guess my XP mileage
does differ..

Dick

Tony Mechelynck

unread,
Aug 16, 2008, 5:39:28 PM8/16/08
to vim...@googlegroups.com
On 16/08/08 23:28, Dick Moores wrote:
[...]

> OK, I just did a
>
> gvim -p *.vim
>
> I didn't SEE anything happen--no files opening, each in their own
> tabs. But when I checked the Buffers menu, I saw that 19 had been
> opened for .vim files. But where are the tabs? I guess my XP mileage
> does differ..
>
> Dick
[...]

Normally, they are near the top of your gvim window, between the toolbar
and the text proper.

If you don't see them, this will make them appear in gvim:

:set showtabline=2 guioptions+=e


Best regards,
Tony.
--
"I know the answer! The answer lies within the heart of all mankind!
The answer is twelve? I think I'm in the wrong building."
-- Charles Schulz

Dick Moores

unread,
Aug 16, 2008, 6:00:37 PM8/16/08
to vim...@googlegroups.com
At 02:39 PM 8/16/2008, Tony Mechelynck wrote:

>On 16/08/08 23:28, Dick Moores wrote:
>[...]
> > OK, I just did a
> >
> > gvim -p *.vim
> >
> > I didn't SEE anything happen--no files opening, each in their own
> > tabs. But when I checked the Buffers menu, I saw that 19 had been
> > opened for .vim files. But where are the tabs? I guess my XP mileage
> > does differ..
> >
> > Dick
>[...]
>
>Normally, they are near the top of your gvim window, between the toolbar
>and the text proper.
>
>If you don't see them, this will make them appear in gvim:
>
> :set showtabline=2 guioptions+=e

I put that in _gvimrc, and now a file does open in a tab, but when I
open a 2nd file, the first tab closes (but buffer remains open) and
the 2nd file opens in a tab. So only one tab open at a time, it
seems. What I want is for a file to stay open in its tab even when
other files are opened in THEIR tabs. And to not have to do
something extra every time to make this happen. In my experience,
this is the way most IDEs work..

Dick

Tony Mechelynck

unread,
Aug 16, 2008, 6:36:08 PM8/16/08
to vim...@googlegroups.com

Try

gvim -p10 *.vim

This should open the first 10 of your 19 files in 10 different tabs (10
tabs is the default maximum; more than that is possible by changing an
option, but they wouldn't be very readable, especially if you're using
long filenames).

Or else,
:tab split | next

should open the next file (of those named on the command-line) in a new tab.

Similarly,
:tabedit filename.ext

opens file "filename.ext" in a new tab.

See ":help tabpage.txt".


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
119. You are reading a book and look for the scroll bar to get to
the next page.

Dick Moores

unread,
Aug 16, 2008, 7:04:45 PM8/16/08
to vim...@googlegroups.com

No. That open just one tab labeled '-p'. The rest were listed on the
Buffer menu.

>(10
>tabs is the default maximum; more than that is possible by changing an
>option, but they wouldn't be very readable, especially if you're using
>long filenames).
>
>Or else,
> :tab split | next
>
>should open the next file (of those named on the command-line) in a new tab.
>
>Similarly,
> :tabedit filename.ext
>
>opens file "filename.ext" in a new tab.

But with that I have to list the files I want to open. I just want
the files I open, no matter how I open them, to open in a new tab
without replacing a tab already open with another file. Maybe this
isn't possible with gvim, but you'd think it would be. In fact, I'm
wondering why it isn't the default behavior.

>See ":help tabpage.txt".

Yes. Lots of info there. Maybe what I'm looking for is too.

Thanks,

Dick

"hundred-and-one symptoms of being an internet addict:
119. You are reading a book and look for the scroll bar to get to
the next page."

I've begun to think that soon when putting down the pencil I've just
written a note with, I'll find myself reaching for the Esc key that
isn't there.

Tony Mechelynck

unread,
Aug 16, 2008, 7:18:29 PM8/16/08
to vim...@googlegroups.com
On 17/08/08 01:04, Dick Moores wrote:
> At 03:36 PM 8/16/2008, Tony Mechelynck wrote:
[...]

>> Try
>>
>> gvim -p10 *.vim
>>
>> This should open the first 10 of your 19 files in 10 different tabs
>
> No. That open just one tab labeled '-p'. The rest were listed on the
> Buffer menu.
[...]

Works for me. Try

gvim -N -u NORC -U NONE -p *.vim

If it works, there is something in your vimrc and/or in your gvimrc
which prevents opening the files in tabs. If it doesn't work, then maybe
you're using a gvim version with limited capabilities -- in that case,
listing the top part of the output of ":version" might be useful. See
":help :redir" about how to capture that output.


Best regards,
Tony.
--
Truthful, adj.:
Dumb and illiterate.
-- Ambrose Bierce, "The Devil's Dictionary"

Dick Moores

unread,
Aug 16, 2008, 7:31:33 PM8/16/08
to vim...@googlegroups.com
At 04:18 PM 8/16/2008, Tony Mechelynck wrote:

>On 17/08/08 01:04, Dick Moores wrote:
> > At 03:36 PM 8/16/2008, Tony Mechelynck wrote:
>[...]
> >> Try
> >>
> >> gvim -p10 *.vim
> >>
> >> This should open the first 10 of your 19 files in 10 different tabs
> >
> > No. That open just one tab labeled '-p'. The rest were listed on the
> > Buffer menu.
>[...]
>
>Works for me. Try
>
> gvim -N -u NORC -U NONE -p *.vim

Nope. Just one tab labeled '-N'.


>If it works, there is something in your vimrc and/or in your gvimrc
>which prevents opening the files in tabs. If it doesn't work, then maybe
>you're using a gvim version with limited capabilities -- in that case,
>listing the top part of the output of ":version" might be useful.

See attached.

> See
>":help :redir" about how to capture that output.

I interested in getting that to work, but have failed so far.

Thanks,

Dick

gvim_version_info.jpg

Tony Mechelynck

unread,
Aug 16, 2008, 7:56:05 PM8/16/08
to vim...@googlegroups.com
On 17/08/08 01:31, Dick Moores wrote:
> At 04:18 PM 8/16/2008, Tony Mechelynck wrote:
>
>> On 17/08/08 01:04, Dick Moores wrote:
>>> At 03:36 PM 8/16/2008, Tony Mechelynck wrote:
>> [...]
>>>> Try
>>>>
>>>> gvim -p10 *.vim
>>>>
>>>> This should open the first 10 of your 19 files in 10 different tabs
>>> No. That open just one tab labeled '-p'. The rest were listed on the
>>> Buffer menu.
>> [...]
>>
>> Works for me. Try
>>
>> gvim -N -u NORC -U NONE -p *.vim
>
> Nope. Just one tab labeled '-N'.

Are you sure you put no space between each dash/minus sign and what
followed it?

Oh, an idea. Maybe you've got a bad gvim.bat early in your PATH. Try
replacing gvim by gvim.exe in the above command (assuming you're on
Windows).

>
>
>> If it works, there is something in your vimrc and/or in your gvimrc
>> which prevents opening the files in tabs. If it doesn't work, then maybe
>> you're using a gvim version with limited capabilities -- in that case,
>> listing the top part of the output of ":version" might be useful.
>
> See attached.

Big version, and compiled with +windows. It ought to work.

>
>> See
>> ":help :redir" about how to capture that output.
>
> I interested in getting that to work, but have failed so far.
>
> Thanks,
>
> Dick

Best regards,
Tony.
--
Ignisecond, n.:
The overlapping moment of time when the hand is locking the car
door even as the brain is saying, "my keys are in there!"
-- Rich Hall, "Sniglets"

Dick Moores

unread,
Aug 16, 2008, 8:14:07 PM8/16/08
to vim...@googlegroups.com
At 04:56 PM 8/16/2008, Tony Mechelynck wrote:

>On 17/08/08 01:31, Dick Moores wrote:
> > At 04:18 PM 8/16/2008, Tony Mechelynck wrote:
> >
> >> On 17/08/08 01:04, Dick Moores wrote:
> >>> At 03:36 PM 8/16/2008, Tony Mechelynck wrote:
> >> [...]
> >>>> Try
> >>>>
> >>>> gvim -p10 *.vim
> >>>>
> >>>> This should open the first 10 of your 19 files in 10 different tabs
> >>> No. That open just one tab labeled '-p'. The rest were listed on the
> >>> Buffer menu.
> >> [...]
> >>
> >> Works for me. Try
> >>
> >> gvim -N -u NORC -U NONE -p *.vim
> >
> > Nope. Just one tab labeled '-N'.
>
>Are you sure you put no space between each dash/minus sign and what
>followed it?

Yes. I just pasted yours.

>Oh, an idea. Maybe you've got a bad gvim.bat early in your PATH. Try
>replacing gvim by gvim.exe in the above command (assuming you're on
>Windows).

XP. Nope--just one tab, labeled '.exe'.

Dick


> >
> >
> >> If it works, there is something in your vimrc and/or in your gvimrc
> >> which prevents opening the files in tabs. If it doesn't work, then maybe
> >> you're using a gvim version with limited capabilities -- in that case,
> >> listing the top part of the output of ":version" might be useful.
> >
> > See attached.
>
>Big version, and compiled with +windows. It ought to work.

I've pasted _vimrc at <http://pastebin.com/fc5bcedc>
and _gvimrc at <http://pastebin.com/f381865d6>

Dick


Dick Moores

unread,
Aug 16, 2008, 8:14:07 PM8/16/08
to vim...@googlegroups.com
At 04:56 PM 8/16/2008, Tony Mechelynck wrote:

>On 17/08/08 01:31, Dick Moores wrote:
> > At 04:18 PM 8/16/2008, Tony Mechelynck wrote:
> >
> >> On 17/08/08 01:04, Dick Moores wrote:
> >>> At 03:36 PM 8/16/2008, Tony Mechelynck wrote:
> >> [...]
> >>>> Try
> >>>>
> >>>> gvim -p10 *.vim
> >>>>
> >>>> This should open the first 10 of your 19 files in 10 different tabs
> >>> No. That open just one tab labeled '-p'. The rest were listed on the
> >>> Buffer menu.
> >> [...]
> >>
> >> Works for me. Try
> >>
> >> gvim -N -u NORC -U NONE -p *.vim
> >
> > Nope. Just one tab labeled '-N'.
>
>Are you sure you put no space between each dash/minus sign and what
>followed it?

Yes. I just pasted yours.

>Oh, an idea. Maybe you've got a bad gvim.bat early in your PATH. Try


>replacing gvim by gvim.exe in the above command (assuming you're on
>Windows).

XP. Nope--just one tab, labeled '.exe'.

Dick


> >
> >


> >> If it works, there is something in your vimrc and/or in your gvimrc
> >> which prevents opening the files in tabs. If it doesn't work, then maybe
> >> you're using a gvim version with limited capabilities -- in that case,
> >> listing the top part of the output of ":version" might be useful.
> >
> > See attached.
>
>Big version, and compiled with +windows. It ought to work.

I've pasted _vimrc at <http://pastebin.com/fc5bcedc>

Bill McCarthy

unread,
Aug 16, 2008, 8:25:40 PM8/16/08
to Dick Moores
On Sat 16-Aug-08 4:28pm -0600, Dick Moores wrote:
>
> At 12:12 PM 8/16/2008, Dave Land wrote:
>
>>On Aug 16, 2008, at 9:41 AM, Dick Moores wrote:
>>
>> > How can I configure gvim to have every file I open, open into a new
>> > tab in the same instance of gvim, not a new instance?
>>
>>If you're using gvim from the command-line, this should help:
>>
>>:help -p
>>
>>This does exactly what you want.
>>
>>If I'm on the command line (I'm on Mac OS X, so YMMV), if I issue the
>>following command:
>>
>>gvim -p *.jsp
>
> OK, I just did a
>
> gvim -p *.vim
>
> I didn't SEE anything happen--no files opening, each in their own
> tabs. But when I checked the Buffers menu, I saw that 19 had been
> opened for .vim files. But where are the tabs? I guess my XP mileage
> does differ..

No, it works fine in XP. Just try:

gvim -u NONE -N -p *.vim

BTW, I read your question two other ways. One is how to add
new files to your current session from Gvim.

:help tabedit

The other is how to add tabs to a running Gvim from the
shell. That could be done with:

gvim -p --remote-tab-silent *.vim

--
Best regards,
Bill

Bill McCarthy

unread,
Aug 16, 2008, 8:33:49 PM8/16/08
to Dick Moores
On Sat 16-Aug-08 6:04pm -0600, Dick Moores wrote:

> At 03:36 PM 8/16/2008, Tony Mechelynck wrote:

>>Try
>>
>> gvim -p10 *.vim
>>
>>This should open the first 10 of your 19 files in 10 different tabs

> No. That open just one tab labeled '-p'. The rest were listed on the
> Buffer menu.

Then try this:

gvim.exe -p *.vim

to make sure you're not running some batch file. I didn't
install those so I can't look at them.

--
Best regards,
Bill

Tony Mechelynck

unread,
Aug 16, 2008, 8:37:28 PM8/16/08
to vim...@googlegroups.com
On 17/08/08 02:14, Dick Moores wrote:
> At 04:56 PM 8/16/2008, Tony Mechelynck wrote:
>
>> On 17/08/08 01:31, Dick Moores wrote:
>>> At 04:18 PM 8/16/2008, Tony Mechelynck wrote:
>>>
>>>> On 17/08/08 01:04, Dick Moores wrote:
>>>>> At 03:36 PM 8/16/2008, Tony Mechelynck wrote:
>>>> [...]
>>>>>> Try
>>>>>>
>>>>>> gvim -p10 *.vim
>>>>>>
>>>>>> This should open the first 10 of your 19 files in 10 different tabs
>>>>> No. That open just one tab labeled '-p'. The rest were listed on the
>>>>> Buffer menu.
>>>> [...]
>>>>
>>>> Works for me. Try
>>>>
>>>> gvim -N -u NORC -U NONE -p *.vim
>>> Nope. Just one tab labeled '-N'.
>> Are you sure you put no space between each dash/minus sign and what
>> followed it?
>
> Yes. I just pasted yours.
>
>> Oh, an idea. Maybe you've got a bad gvim.bat early in your PATH. Try
>> replacing gvim by gvim.exe in the above command (assuming you're on
>> Windows).
>
> XP. Nope--just one tab, labeled '.exe'.

That is really wrong. Well, open a cmd.exe window (aka "Dos Box"), cd to
the directory containing gvim.exe (probably "C:\Program
Files\Vim\vim72", or if not that, then maybe "C:\Vim\vim72"), and type

.\gvim.exe -N -u NORC -U NONE -p *.vim

at the prompt, then (of course) hit Enter. If it still doesn't work, I
don't know how to make it work.

>
> Dick
>
>
>>>
>>>> If it works, there is something in your vimrc and/or in your gvimrc
>>>> which prevents opening the files in tabs. If it doesn't work, then maybe
>>>> you're using a gvim version with limited capabilities -- in that case,
>>>> listing the top part of the output of ":version" might be useful.
>>> See attached.
>> Big version, and compiled with +windows. It ought to work.
>
> I've pasted _vimrc at<http://pastebin.com/fc5bcedc>
> and _gvimrc at<http://pastebin.com/f381865d6>
>
> Dick

Best regards,
Tony.
--
Vidi, vici, veni.
(I saw, I conquered, I came.)

Dick Moores

unread,
Aug 16, 2008, 8:42:51 PM8/16/08
to vim...@googlegroups.com
At 05:25 PM 8/16/2008, Bill McCarthy wrote:

>On Sat 16-Aug-08 4:28pm -0600, Dick Moores wrote:
> >
> > At 12:12 PM 8/16/2008, Dave Land wrote:
> >
> >>On Aug 16, 2008, at 9:41 AM, Dick Moores wrote:
> >>
> >> > How can I configure gvim to have every file I open, open into a new
> >> > tab in the same instance of gvim, not a new instance?
> >>
> >>If you're using gvim from the command-line, this should help:
> >>
> >>:help -p
> >>
> >>This does exactly what you want.
> >>
> >>If I'm on the command line (I'm on Mac OS X, so YMMV), if I issue the
> >>following command:
> >>
> >>gvim -p *.jsp
> >
> > OK, I just did a
> >
> > gvim -p *.vim
> >
> > I didn't SEE anything happen--no files opening, each in their own
> > tabs. But when I checked the Buffers menu, I saw that 19 had been
> > opened for .vim files. But where are the tabs? I guess my XP mileage
> > does differ..
>
>No, it works fine in XP. Just try:
>
> gvim -u NONE -N -p *.vim

I get one tab, labeled '-u', and a bunch of buffers on the Buffer menu.

>BTW, I read your question two other ways. One is how to add
>new files to your current session from Gvim.
>
> :help tabedit

I already have these lines in _gvimrc:
ab grc :tabnew ~/_gvimrc
ab vrc :tabnew ~/_vimrc
ab notes :tabnew ~/scrap.txt

They open those files the way I want them opened. But that's only 3.
Do I have to make another ab for each file I might want to open?

>The other is how to add tabs to a running Gvim from the
>shell. That could be done with:
>
> gvim -p --remote-tab-silent *.vim

I get one tab, labeled '-p', and a bunch of buffers on the Buffer menu.

Thanks,

Dick


Dick Moores

unread,
Aug 16, 2008, 8:51:00 PM8/16/08
to vim...@googlegroups.com

Yes, that worked. It opened a bunch of *.vim files. But ignored all
the settings in my _vimrc and _gvimrc, so not good. But anyway,
that's not really what I'm after, as I''ve said before.

Dick


Dick Moores

unread,
Aug 16, 2008, 8:51:00 PM8/16/08
to vim...@googlegroups.com

Yes, that worked. It opened a bunch of *.vim files. But ignored all

Tony Mechelynck

unread,
Aug 16, 2008, 9:36:54 PM8/16/08
to vim...@googlegroups.com

At least it proves the binary is OK.

Now try the same, still at the cmd.exe prompt, but with only

.\gvim.exe -p *.vim

If this _doesn't_ work, then we know the error is somewhere in your
vimrc or gvimrc (because the only difference is that now gvim uses your
vimrc and gvimrc). To know where the fault lies, first rename either
your vimrc or your gvimrc to something else, so you'll know which one is
at fault. Then rename it back, but wrap approximately half of the
contents of the suspect file between ":if 0" and ":endif" to comment it
out (beware that this should of course not have one end inside and the
other outside the range of an already existing ":if" statement). This
way, you should be able to narrow the problem down to smaller and
smaller parts of the suspect file until you find out which line is at fault.

If it does work this way, then your vimrc and gvimrc are OK, but the way
you used to load gvim (before using cmd.exe) is suspect.


Best regards,
Tony.
--
Try not to have a good time ... This is supposed to be educational.
-- Charles Schulz

Dick Moores

unread,
Aug 16, 2008, 10:11:31 PM8/16/08
to vim...@googlegroups.com

It worked fine!


>If this _doesn't_ work, then we know the error is somewhere in your
>vimrc or gvimrc (because the only difference is that now gvim uses your
>vimrc and gvimrc). To know where the fault lies, first rename either
>your vimrc or your gvimrc to something else, so you'll know which one is
>at fault. Then rename it back, but wrap approximately half of the
>contents of the suspect file between ":if 0" and ":endif" to comment it
>out (beware that this should of course not have one end inside and the
>other outside the range of an already existing ":if" statement). This
>way, you should be able to narrow the problem down to smaller and
>smaller parts of the suspect file until you find out which line is at fault.

Interesting plan!


>If it does work this way, then your vimrc and gvimrc are OK, but the way
>you used to load gvim (before using cmd.exe) is suspect.

What now?

Dick


Tony Mechelynck

unread,
Aug 16, 2008, 10:53:12 PM8/16/08
to vim...@googlegroups.com
On 17/08/08 04:11, Dick Moores wrote:
> At 06:36 PM 8/16/2008, Tony Mechelynck wrote:
[...]

>> Now try the same, still at the cmd.exe prompt, but with only
>>
>> .\gvim.exe -p *.vim
>
> It worked fine!
>
[...]

>> If it does work this way, then your vimrc and gvimrc are OK, but the way
>> you used to load gvim (before using cmd.exe) is suspect.
>
> What now?
>
> Dick

Well, now you know one way to start gvim which will work, and use your
vimrc and gvimrc, even for multitab editing. If you find this method too
cumbersome, we can try to debug your previous method, but for that
you'll have to describe it in detail, and it may take some time before
we find the error(s) -- and BTW I'm going to bed in a few minutes, but
I'm sure other people will have a look at anything you post. OTOH, if
starting gvim from cmd.exe is OK for you (it used to be OK for me when I
was on Windows) then we can leave it at that.


Best regards,
Tony.
--
The income tax has made more liars out of the American people than golf
has. Even when you make a tax form out on the level, you don't know
when it's through if you are a crook or a martyr.
-- Will Rogers

Ben Schmidt

unread,
Aug 19, 2008, 7:38:28 PM8/19/08
to vim...@googlegroups.com
>> No, it works fine in XP. Just try:
>>
>> gvim -u NONE -N -p *.vim
>
> I get one tab, labeled '-u', and a bunch of buffers on the Buffer menu.

Where are you typing that command, i.e. in what program, etc.? It smells
like there's some shell alias set up or something. I don't know how
that's done in Windows really, or how to undo it, but at least knowing
where you're typing the command will be a start...

Ben.


Peter Odding

unread,
Aug 19, 2008, 8:40:44 PM8/19/08
to vim...@googlegroups.com
Ben Schmidt wrote:
> Where are you typing that command, i.e. in what program, etc.? It smells
> like there's some shell alias set up or something. I don't know how
> that's done in Windows really, or how to undo it, but at least knowing
> where you're typing the command will be a start...

The Windows command-prompt supports `doskey' to add aliases for
interactive commands and batch scripts in directories in the %PATH% can
also override executables further down the %PATH%. I'd be surprised if
this is the issue though, because how would you add such an alias
without noticing it? (unless such a Batch script came with the Windows
distribution of Vim, but then more users would have reported issues)

- Peter Odding

Dick Moores

unread,
Aug 19, 2008, 9:08:38 PM8/19/08
to vim...@googlegroups.com

In gvim, at the command line reached by a ':'

Dikc


Tony Mechelynck

unread,
Aug 19, 2008, 9:33:42 PM8/19/08
to vim...@googlegroups.com

That's not what Ben meant. You hopefully weren't typing ":gvim -u NONE
-p *.vim" in a preexisting gvim instance. (If you did, you shouldn't
have, and that's where the problems came from.) How were you starting
gvim to get the above symptoms?


Best regards,
Tony.
--
When I was a boy I was told that anybody could become President. Now
I'm beginning to believe it.
-- Clarence Darrow

Dick Moores

unread,
Aug 19, 2008, 10:14:42 PM8/19/08
to vim...@googlegroups.com
At 06:33 PM 8/19/2008, Tony Mechelynck wrote:

>On 20/08/08 03:08, Dick Moores wrote:
> > At 04:38 PM 8/19/2008, Ben Schmidt wrote:
> >
> >>>> No, it works fine in XP. Just try:
> >>>>
> >>>> gvim -u NONE -N -p *.vim
> >>> I get one tab, labeled '-u', and a bunch of buffers on the Buffer menu.
> >> Where are you typing that command, i.e. in what program, etc.? It smells
> >> like there's some shell alias set up or something. I don't know how
> >> that's done in Windows really, or how to undo it, but at least knowing
> >> where you're typing the command will be a start...
> >
> > In gvim, at the command line reached by a ':'
> >
> > Dikc
>
>That's not what Ben meant.

But he asked where I typed the command. I told him. I do seem to be
having trouble with vim-speak.

>You hopefully weren't typing ":gvim -u NONE
>-p *.vim" in a preexisting gvim instance.

Yes, I was.

> (If you did, you shouldn't
>have, and that's where the problems came from.) How were you starting
>gvim to get the above symptoms?

I always start it, as I believe I've said before, using a shortcut
key (Ctrl+Alt+G) for gvim.exe.

OK, just now I tried gvim -u NONE -N -p *.vim at the XP command
line, after CD-ing around to where gvim.exe is. It opened 10 .vim
files (in that directory) in separate tabs, while ignoring the many
configurations I had set up for gvim.

Dick


Ben Schmidt

unread,
Aug 19, 2008, 10:34:53 PM8/19/08
to vim...@googlegroups.com

Aha! That explains it!

The :gvim command supports different things to what gvim.exe supports on
the commandline. It is more like the :e command.

If you are already inside Vim and want to open a bunch of files in tabs,
I would suggest this way:

:tab sn *.vim
:tab sall

The first command sets Vim's argument list, editing the first one in a
new tab. The second command tells Vim to make a tab for every file in
the list. Their full names are :snext (split next) and :sall (split
all), and :tab before them makes them work with tabs rather than split
windows (panes).

:help :tab
:help :snext
:help :sall

If you just want to open a single file in a new tab, simply

:tabe filename.txt

will do. Full name :tabedit.

You can make user commands to make all this easier to remember if you
like--ask if you'd like a hand with that, as it isn't trivial.

Some people prefer a command that will switch to an existing tab if the
file is already being edited, too. I think there is a tip about that on
the Vim tips wiki:

http://vim.wikia.com/

so you might like to have a bit of a search around there. You might need
'tabpage' not 'tab' to find stuff.

Cheers,

Ben.


Tony Mechelynck

unread,
Aug 19, 2008, 10:40:52 PM8/19/08
to vim...@googlegroups.com

Well, that's what we expected from the start that it should have done;
and I expect that it did obey anything in the _vimrc and/or _gvimrc (if
any) in your home directory (as seen by Vim) or failing that, in $VIM
(if any).

When someone on this group gives an example of a command starting with
vim, gvim, view, gview, vimdiff, gvimdiff, etc., with no initial colon,
it is usually meant to be run either at the shell prompt ("the shell" is
usually cmd.exe on Windows but it might be 4NT.exe etc.; on Unix it may
be one a number of programs, usually with names ending in sh) or in the
graphical OS interface's "Execute" popup. (How that popup is brought up
varies from OS to OS. Here on Linux with KDE I hit Alt-F2.)

Commands meant to be typed at the Vim command-line are usually given
with the initial colon.

Vim ex-commands meant to be typed into a script (such as the vimrc) are
sometimes given with the initial colon, especially if they could also be
typed at the Vim command-line, but they are more often given without the
colon.


Best regards,
Tony.
--

hundred-and-one symptoms of being an internet addict:

129. You cancel your newspaper subscription.

Dick Moores

unread,
Aug 19, 2008, 11:13:25 PM8/19/08
to vim...@googlegroups.com
At 07:34 PM 8/19/2008, Ben Schmidt wrote:

>Dick Moores wrote:
> > At 04:38 PM 8/19/2008, Ben Schmidt wrote:
> >
> >>>> No, it works fine in XP. Just try:
> >>>>
> >>>> gvim -u NONE -N -p *.vim
> >>> I get one tab, labeled '-u', and a bunch of buffers on the Buffer menu.
> >> Where are you typing that command, i.e. in what program, etc.? It smells
> >> like there's some shell alias set up or something. I don't know how
> >> that's done in Windows really, or how to undo it, but at least knowing
> >> where you're typing the command will be a start...
> >
> > In gvim, at the command line reached by a ':'
>
>Aha! That explains it!
>
>The :gvim command supports different things to what gvim.exe supports on
>the commandline. It is more like the :e command.
>
>If you are already inside Vim and want to open a bunch of files in tabs,

No, for what I really want can be understood by taking a look at this
thread from my beginning post:
<http://groups.google.com/group/vim_use/browse_thread/thread/0f62850943f26c3d/28097d2f4e6320b7#28097d2f4e6320b7>

Thanks to Tony, I have
set showtabline=2 guioptions+=e
in my _gvimrc

Because of this, when I call gvim.exe, it opens with one tab labeled
'[No Name]'. If I want to open another file, I can right-click on
that tab and a dialog box will open for a directory. If the file I
want is there, fine. But if it's not, I have to do some--maybe a
lot--of changing around to the right directory. This trouble was the
reason for my original post.

I have set up a bunch of ab's that will open dialog boxes for various
directories. Examples:
ab pw :browse e E:\PythonWork
ab riley :browse e C:\Documents and Settings\Riley

So I can save the trouble I mentioned above by using these, but a
files chosen from a dialog box doesn't open in its own new tab.

What I do for files that I open frequently is write an ab for each
one, such as this:
ab v :tabnew ~/_vimrc

But what I really want, as I wrote earlier in the thread, is to have
any file I open, open in its own new tab, now matter how I accessed
it to open it.

I'm not interested (I think) in opening ALL files in a directory
having the same extension, say .vim or .py or .txt.

Dick

Ben Schmidt

unread,
Aug 19, 2008, 11:13:21 PM8/19/08
to vim...@googlegroups.com
>>>>>>> No, it works fine in XP. Just try:
>>>>>>>
>>>>>>> gvim -u NONE -N -p *.vim
>>>>>> I get one tab, labeled '-u', and a bunch of buffers on the Buffer menu.
>>>>> Where are you typing that command, i.e. in what program, etc.?
>>>> In gvim, at the command line reached by a ':'
>>> That's not what Ben meant.
>> But he asked where I typed the command. I told him. I do seem to be
>> having trouble with vim-speak.

Hehe, nope, you were right; that was exactly what I meant. :-) I've
replied in another post with essentially an answer to what I now believe
your original question was!

>> OK, just now I tried gvim -u NONE -N -p *.vim at the XP command
>> line, after CD-ing around to where gvim.exe is. It opened 10 .vim
>> files (in that directory) in separate tabs, while ignoring the many
>> configurations I had set up for gvim.
>

> Well, that's what we expected from the start that it should have done;
> and I expect that it did obey anything in the _vimrc and/or _gvimrc (if
> any) in your home directory (as seen by Vim) or failing that, in $VIM
> (if any).

Not with the -u NONE, Tony (as you well know, but evidently didn't
notice or something).

Omit that part of the command and I expect it will pick up the same
customisations as when using your key shortcut, Dick.

But hey, if you always use the shortcut, you don't need this anyway.

Smiles,

Ben.


Dick Moores

unread,
Aug 19, 2008, 11:21:40 PM8/19/08
to vim...@googlegroups.com

No, it didn't. Just off the top of my head, it ignored:
set nu
colorscheme peaksea
set lines=41 columns=150


ab pw :browse e E:\PythonWork

>When someone on this group gives an example of a command starting with
>vim, gvim, view, gview, vimdiff, gvimdiff, etc., with no initial colon,
>it is usually meant to be run either at the shell prompt ("the shell" is
>usually cmd.exe on Windows but it might be 4NT.exe etc.; on Unix it may
>be one a number of programs, usually with names ending in sh) or in the
>graphical OS interface's "Execute" popup. (How that popup is brought up
>varies from OS to OS. Here on Linux with KDE I hit Alt-F2.)
>
>Commands meant to be typed at the Vim command-line are usually given
>with the initial colon.
>
>Vim ex-commands meant to be typed into a script (such as the vimrc) are
>sometimes given with the initial colon, especially if they could also be
>typed at the Vim command-line, but they are more often given without the
>colon.

Got it. Thanks.


Tony Mechelynck

unread,
Aug 19, 2008, 11:33:04 PM8/19/08
to vim...@googlegroups.com
On 20/08/08 05:13, Dick Moores wrote:
[...]

> Because of this, when I call gvim.exe, it opens with one tab labeled
> '[No Name]'. If I want to open another file, I can right-click on
> that tab and a dialog box will open for a directory. If the file I
> want is there, fine. But if it's not, I have to do some--maybe a
> lot--of changing around to the right directory. This trouble was the
> reason for my original post.
[...]

If you know which directory you want to reach, then there are several
possibilities:

:cd /some/directory

makes that directory current. You can also use a relative path (starting
with neither / nor, on Windows, \ or a drive letter).

:e /some/directory/

shows the list of files in that directory. Then move the cursor about,
and hit Enter to replace the directory list by the contents of the file
or directory under the cursor, or hit o to edit it in a split window.
Hit F1 for help about other things you may do in that directory-list window.

:set wildmenu
:e /some/directory/<Tab>

gives a menu of the contents of that directory. Hit the left or right
arrow to select, the down arrow to go to a subdirectory, the up arrow to
go to the parent directory, Enter to accept the current selection, Esc
to cancel, or else type a few letters then Tab again to narrow down the
search, etc.

and of course

:e /some/directory/filename.ext

to edit the file, or

:tabedit /some/directory/filename.ext

to edit it in a new tab.


If you don't know in which directory your file is located, all hope
isn't lost yet: see

:help :find
:help 'path'


Best regards,
Tony.
--
Religion has done love a great service by making it a sin.
-- Anatole France

Tony Mechelynck

unread,
Aug 19, 2008, 11:35:40 PM8/19/08
to vim...@googlegroups.com
On 20/08/08 05:13, Ben Schmidt wrote:
>>>>>>>> No, it works fine in XP. Just try:
>>>>>>>>
>>>>>>>> gvim -u NONE -N -p *.vim
>>>>>>> I get one tab, labeled '-u', and a bunch of buffers on the Buffer menu.
>>>>>> Where are you typing that command, i.e. in what program, etc.?
>>>>> In gvim, at the command line reached by a ':'
>>>> That's not what Ben meant.
>>> But he asked where I typed the command. I told him. I do seem to be
>>> having trouble with vim-speak.
>
> Hehe, nope, you were right; that was exactly what I meant. :-) I've
> replied in another post with essentially an answer to what I now believe
> your original question was!
>
>>> OK, just now I tried gvim -u NONE -N -p *.vim at the XP command
>>> line, after CD-ing around to where gvim.exe is. It opened 10 .vim
>>> files (in that directory) in separate tabs, while ignoring the many
>>> configurations I had set up for gvim.
>> Well, that's what we expected from the start that it should have done;
>> and I expect that it did obey anything in the _vimrc and/or _gvimrc (if
>> any) in your home directory (as seen by Vim) or failing that, in $VIM
>> (if any).
>
> Not with the -u NONE, Tony (as you well know, but evidently didn't
> notice or something).

Oops, maybe I should go to bed. (I have a teapot right next to me at the
mo'.)

>
> Omit that part of the command and I expect it will pick up the same
> customisations as when using your key shortcut, Dick.
>
> But hey, if you always use the shortcut, you don't need this anyway.
>
> Smiles,
>
> Ben.

Best regards,


Tony.
--
hundred-and-one symptoms of being an internet addict:

130. You can't get out of your desk even if it's time to eat or time
to go to the bathroom.

Ben Schmidt

unread,
Aug 19, 2008, 11:52:01 PM8/19/08
to vim...@googlegroups.com
> I have set up a bunch of ab's that will open dialog boxes for various
> directories. Examples:
> ab pw :browse e E:\PythonWork
> ab riley :browse e C:\Documents and Settings\Riley
>
> So I can save the trouble I mentioned above by using these, but a
> files chosen from a dialog box doesn't open in its own new tab.

Easy! Change the e in those commands to tabe so it uses the :tabedit
command, not the :edit command after browsing.

If you installed the Vim shell extension, you can also right-click a
file in Windows Explorer and choose some Edit with existing Vim variant
that will use a new tab, I believe.

> But what I really want, as I wrote earlier in the thread, is to have
> any file I open, open in its own new tab, now matter how I accessed
> it to open it.

It can't be done in a completely blanket way to cover everything. You
just need to learn the appropriate Vim commands that work this way and
use them, rather than alternatives that don't (which are usually the
ones you learn first!). Sometimes you need to make user commands or
mappings to do what you want. E.g. to make the CTRL-W_f command use a
new tab:

:noremap <C-w>f <C-w>f<C-w>T

or you could make gf do it with

:noremap gf <C-w>f<C-w>T

but I'd recommend against that, as after a while using lots of separate
tabs, I think you'll find you actually quite like to be able to browse
around between files without opening new tabs all the time... Vim's
commands like CTRL-O and CTRL-^ make this kind of browsing pretty
convenient and there's much less clutter.

Cheers,

Ben.


Benjamin Fritz

unread,
Aug 20, 2008, 9:30:25 AM8/20/08
to vim...@googlegroups.com
On Tue, Aug 19, 2008 at 9:34 PM, Ben Schmidt
<mail_ben...@yahoo.com.au> wrote:
>
> Some people prefer a command that will switch to an existing tab if the
> file is already being edited, too. I think there is a tip about that on
> the Vim tips wiki:
>
> http://vim.wikia.com/
>

Especially, browse this category:

http://vim.wikia.com/wiki/Category:Tabs

Reply all
Reply to author
Forward
0 new messages