Proposal: new options for 'vertical' and 'horizontal' splits by default

700 views
Skip to first unread message

Kartik Agaram

unread,
Sep 23, 2010, 5:30:08 PM9/23/10
to vim...@vim.org
I've been thinking about adding two options to vim:
:set horizontal [default]
:set vertical

What they would do is set the default split orientation for commands
like C-w C-] (http://thread.gmane.org/gmane.editors.vim/48415), :diff
and so on. Normal commands currently switch orientation using
:vertical, but that option doesn't exist for keyboard shortcuts
without more invasive scripting, and every shortcut that splits a
window must be similarly modified with a lot of boilerplate.

Has this been considered before? Are there any major roadblocks I
should be aware of? (I haven't looked at the vim codebase in ~4 years)
A search quickly brought up several threads that would be served by
this change:

http://thread.gmane.org/gmane.editors.vim/48415
http://thread.gmane.org/gmane.editors.vim/25381
http://thread.gmane.org/gmane.editors.vim.devel/10002
http://article.gmane.org/gmane.editors.vim.devel/12551
via gmane.org/editors.vim: 'vertical split'

But I haven't seen any discussions for a global fix.

If this seems like a good idea I'll start with a documentation patch
for review here.

Thanks,
Kartik
http://akkartik.name
(I ran into this issue several years ago, without thinking of an
option-based solution:
http://vim.wikia.com/wiki/Using_vertical_splits)

Oliver Adams

unread,
Sep 23, 2010, 8:25:12 PM9/23/10
to vim...@googlegroups.com
Yeah i'd really like it if i could set it to split vertically by default

Ollie


--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Christian Brabandt

unread,
Sep 24, 2010, 9:06:07 AM9/24/10
to vim...@googlegroups.com
Hi Kartik!

On Do, 23 Sep 2010, Kartik Agaram wrote:

[split vertical request]
Try the attached patch, it provides the new setting 'splitvertical'

Mit freundlichen Gr��en
Christian
--
Wer zu lange ein Auge zugedr�ckt hat, dem werden eines Tages pl�tzlich
beide aufgehen.
-- Sophia Loren (eig. Maria Scicolone)

verstplit.patch

Kartik Agaram

unread,
Sep 24, 2010, 5:56:40 PM9/24/10
to vim...@googlegroups.com
On Fri, Sep 24, 2010 at 06:06, Christian Brabandt <cbl...@256bit.org> wrote:
> Try the attached patch, it provides the new setting 'splitvertical'

I've only been using it for a couple of hours, but I love it so far.
Has this patch come up before on the list? I'd vote to have it in.
(modulo adding splitvertical and variants to the syntax/vim.vim file)
Let me know if I can help with the process.

Christian Brabandt

unread,
Sep 25, 2010, 7:32:12 AM9/25/10
to vim...@googlegroups.com, Bram Moolenaar
Hi Kartik!

Bram decides what will be included in vim. He might comment on the patch
and then it may or may not be included in Vim. I don't know.

regards,
Christian

Kartik Agaram

unread,
Sep 25, 2010, 12:12:52 PM9/25/10
to vim...@googlegroups.com, Bram Moolenaar
> Bram decides what will be included in vim. He might comment on the patch
> and then it may or may not be included in Vim. I don't know.

Just FYI, I made a couple of tweaks to syntax/vim.vim to include 6
variants of splitvertical as keywords.

Kartik Agaram

unread,
Oct 3, 2010, 3:34:40 PM10/3/10
to vim...@googlegroups.com, Bram Moolenaar

After using splitvertical for a few weeks I find myself wanting a
:horizontal corresponding to the :vertical command, just for those
times I want a horizontal split. Should I just post an updated patch
on the mailing list?

Ben Fritz

unread,
Oct 4, 2010, 9:47:12 AM10/4/10
to vim_dev


On Sep 23, 4:30 pm, Kartik Agaram <a...@akkartik.com> wrote:
> I've been thinking about adding two options to vim:
>   :set horizontal [default]
>   :set vertical
>
> What they would do is set the default split orientation for commands
> like C-w C-] (http://thread.gmane.org/gmane.editors.vim/48415), :diff
> and so on.

This option already exists for :diff. :set diffopt+=vertical or :set
diffopt+=horizontal. This will probably have some weird interactions
with your patch (I have not tried it).

Kartik Agaram

unread,
Oct 4, 2010, 1:19:52 PM10/4/10
to vim...@googlegroups.com
> This option already exists for :diff. :set diffopt+=vertical or :set
> diffopt+=horizontal. This will probably have some weird interactions
> with your patch (I have not tried it).

Not my patch but Christian Brabandt's :)

Thanks for the tip. I just tested it and splitvertical trumps diffopt
horizontal so far. Is that right? Perhaps the configuration for a
specific mode should trump the global setting.

This has now put me over the edge to keeping a list of bugs about this
issue as we find them:
http://vim.wikia.com/wiki/User:Kartik_Agaram
(I wanted it to be in 'vim space', a wiki so anybody could easily
modify the list, and super lightweight so you didn't have to create an
account or login or *anything* to do so.)

Can anybody else think of options that affect split direction in vim?

Christian Brabandt

unread,
Oct 6, 2010, 5:02:03 PM10/6/10
to vim...@googlegroups.com
Hi Kartik!

Attaching updated version of the patch. Contains these improvements:
- implements :hor[izontal] command (now :hor vsp and :sp are
effectively the same)
- Quickfix and Commandwindow are not affected by 'splitvertical' (I
found that really annoying)
- added documentation for :horizontal and 'splitvertical'
- 'splitvertical' does not interfere with 'diffoptions' anymore
- syntax highlighting for vim script items
(I know this file is auto generated, but I don't know how?)

Caveats: This won't probably be included in Vim 7.3 as Bram told me.
Maybe with Vim 7.4

regards,
Christian

splitvertical.patch

Kartik Agaram

unread,
Oct 19, 2010, 12:31:28 PM10/19/10
to vim...@googlegroups.com
Thanks a lot for this patch[1], Christian! I've been using it for a
few weeks now and it's been working absolutely great. It's also
eliminated almost 200 lines from my vimrc.

Today I discovered a new keyboard shortcut: C-w C-s to split
(circuitously via http://news.ycombinator.com/item?id=1807008). I was
going to report it here, but you'd gotten there before me.

One further bug report: :diffsplit, :diffthis and :diffpatch don't
respect 'splitvertical'.

Many thanks,
Kartik

[1] https://groups.google.com/group/vim_dev/msg/679fee5026967b82

Christian Brabandt

unread,
Oct 19, 2010, 1:14:26 PM10/19/10
to vim...@googlegroups.com
Hi Kartik!

On Di, 19 Okt 2010, Kartik Agaram wrote:

> Thanks a lot for this patch[1], Christian! I've been using it for a
> few weeks now and it's been working absolutely great. It's also
> eliminated almost 200 lines from my vimrc.
>
> Today I discovered a new keyboard shortcut: C-w C-s to split
> (circuitously via http://news.ycombinator.com/item?id=1807008). I was
> going to report it here, but you'd gotten there before me.

No I haven't done anything there. But I don't understand that page. It
refers to a graphical representation of the undotree. Though I also
created the histwin plugin, which is similar

>
> One further bug report: :diffsplit, :diffthis and :diffpatch don't
> respect 'splitvertical'.

That was on purpose. For those the 'diffopt' settings apply.

regards,
Christian

Kartik Agaram

unread,
Oct 19, 2010, 1:40:17 PM10/19/10
to vim...@googlegroups.com
>> Today I discovered a new keyboard shortcut: C-w C-s to split
>
> No I haven't done anything there.

My reference to undotree was only marginally relevant. I was just
saying that C-w C-s splits vertically as it should, and its
documentation refers to splitvertical as well. So you were way ahead
of me :)

>> One further bug report: :diffsplit, :diffthis and :diffpatch don't
>> respect 'splitvertical'.
>
> That was on purpose. For those the 'diffopt' settings apply.

Ah. Perhaps diffopt should override splitvertical only if it's set?

Christian Brabandt

unread,
Oct 19, 2010, 2:21:41 PM10/19/10
to vim...@googlegroups.com
Hi Kartik!

On Di, 19 Okt 2010, Kartik Agaram wrote:

> My reference to undotree was only marginally relevant. I was just
> saying that C-w C-s splits vertically as it should, and its
> documentation refers to splitvertical as well. So you were way ahead
> of me :)
>
> >> One further bug report: :diffsplit, :diffthis and :diffpatch don't
> >> respect 'splitvertical'.
> >
> > That was on purpose. For those the 'diffopt' settings apply.
>
> Ah. Perhaps diffopt should override splitvertical only if it's set?

I think, this would make it more complex. I'd like to keep it clean and
don't want to depend one option on another one.

regards,
Christian

Reply all
Reply to author
Forward
0 new messages