vim - Write a command to increase or decrease the number of vertical splits -


i have vim screen split 2 vertical windows, each of may further horizontally split. sometimes, want add or delete vertical window. there way detect how many top-level vertical splits there , add or remove vsplits necessary?

for example, suppose screen looks this:

+--------+--------+ |        |        | |        |        | +--------+        | |        |        | |        |        | |        +--------+ |        |        | +--------+--------+ 

i want :columns 1 give me

+--------+ |        | |        | +--------+ |        | |        | |        | |        | +--------+ 

by closing 2 right-most windows.

i want :columns 2 nothing, detecting 2 columns open.

and want :columns 3 give me

+--------+--------+--------+ |        |        |        | |        |        |        | +--------+        |        | |        |        |        | |        |        |        | |        +--------+        | |        |        |        | +--------+--------+--------+ 

i fine if function ignores vertical splits within horizontal splits. example, if had

+--------+ |        | |        | +---+----+ |   |    | |   |    | |   |    | |   |    | +---+----+ 

and ran :columns 2, get

+--------+--------+ |        |        | |        |        | +---+----+        | |   |    |        | |   |    |        | |   |    |        | |   |    |        | +---+----+--------+ 

there indeed way, involved; first step count currently-open vertical windows, , don’t know of built-in function facilitates this. working approach found start @ first window (the top of first — if not entirety of first — vertical split), , then, using wincmd l, move next window right long wincmd l moves new window, adding each count of open vertical windows including first one. (i think gary fixler referred in comments on question.)

i started trying write code posting here, , grew become larger function want put in ~/.vimrc, ended turning plugin takes above approach , provides :columns command; see columcille (on vim.org @ http://www.vim.org/scripts/script.php?script_id=4742.) plugin provides command managing horizontal split windows: :rows divides current column (or main window, if there no open vertical splits) specified number of “rows.”


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -