Manoj N V
Manoj N V

Reputation: 555

Specifying width for :vsplit in vim

Is there any way to specify a width when doing :vsplit? Also, is there a way to increase or decrease the width on a vertically splitted window? Ctrl-w + and Ctrl-w - seems to be working on only horizontally split windows.

Upvotes: 15

Views: 11643

Answers (5)

Mark K Cowan
Mark K Cowan

Reputation: 1863

Also:

:vs
:vertical resize 30

and:

:sp
:resize 30

I have an Alt+E binding for a vertical file-explorer pane 60 chars wide:

:vs +Explore<CR>:vertical resize 60<CR>

Admittedly, I didn't know about the simple :60vs or :60sp thing in Luis' answer when I wrote that macro.

Upvotes: 0

Andi Hafner
Andi Hafner

Reputation: 339

If you want to fix the adjusted windows width, be sure the cursor is placed inside it and set the boolean

:set winfixwidth

This prevents from unwanted automatic resize of the such locked window width if some other window command like CTRL-= ("make all windows equal") is applied.

:set nowinfixwidth with the cursor placed inside the appropriate window disables the lock.

:mksession stores the window arrangement as calling vim again from the command line like
vim -S Session.vim & restores it.

Hope this helps...

Upvotes: 1

Filipe Felisbino
Filipe Felisbino

Reputation: 2902

You can also use for example 80| to set your current split width to 80 columns

Upvotes: 1

Eulinux
Eulinux

Reputation: 41

Ctrl-W n < works, replace n with the number of steps you want to move.

Upvotes: 4

Luis
Luis

Reputation: 631

According to :help :vsplit, it takes an optional numeric argument as a prefix, e.g., :80vs. Try it out!

Edit: I guess I forgot to mention. You can control the width with Ctrl-W < and Ctrl-W >

For more info, read the manual at :help windows

Upvotes: 32

Related Questions