Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying width for :vsplit in vim

Tags:

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.

like image 845
Manoj N V Avatar asked Sep 07 '09 08:09

Manoj N V


People also ask

How do I resize a tab in vim?

Split resizing To increase a window to its maximum width, use Ctrl-w | . In Gvim and vim in terminals with mouse support, it is also possible to use the mouse to resize a window. Simply grab the statusline at the window border and drag it into the desired direction.

How do I switch between splits in vim?

To move between splits first press Ctrl-w (I remember this by Control Window, I'm not sure what the official mnemonic is) Then press a directional key to move the cursor to the split you're interested in. Directional key could be the arrows or my preferred home row method.


Video Answer


4 Answers

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

like image 103
Luis Avatar answered Oct 16 '22 18:10

Luis


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

like image 42
Eulinux Avatar answered Oct 16 '22 17:10

Eulinux


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

like image 43
Filipe Avatar answered Oct 16 '22 18:10

Filipe


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...

like image 24
Andi Hafner Avatar answered Oct 16 '22 18:10

Andi Hafner