mirror of
https://github.com/neovim/neovim.git
synced 2025-09-22 19:18:34 +00:00
vim-patch:9.0.0342: ":wincmd =" equalizes in two directions
Problem: ":wincmd =" equalizes in two directions.
Solution: Make ":vertical wincmd =" equalize vertically only and
":horizontal wincmd =" equalize horizontally only.
21c3a80a7f
This commit is contained in:
@@ -235,9 +235,16 @@ and 'winminwidth' are relevant.
|
|||||||
*:vert* *:vertical*
|
*:vert* *:vertical*
|
||||||
:vert[ical] {cmd}
|
:vert[ical] {cmd}
|
||||||
Execute {cmd}. If it contains a command that splits a window,
|
Execute {cmd}. If it contains a command that splits a window,
|
||||||
it will be split vertically.
|
it will be split vertically. For `vertical wincmd =` windows
|
||||||
|
will be equialized only vertically.
|
||||||
Doesn't work for |:execute| and |:normal|.
|
Doesn't work for |:execute| and |:normal|.
|
||||||
|
|
||||||
|
*:hor* *:horizontal*
|
||||||
|
:hor[izontal] {cmd}
|
||||||
|
Execute {cmd}. Currently only makes a difference for
|
||||||
|
`horizontal wincmd =`, which will equal windows only
|
||||||
|
horizontally.
|
||||||
|
|
||||||
:lefta[bove] {cmd} *:lefta* *:leftabove*
|
:lefta[bove] {cmd} *:lefta* *:leftabove*
|
||||||
:abo[veleft] {cmd} *:abo* *:aboveleft*
|
:abo[veleft] {cmd} *:abo* *:aboveleft*
|
||||||
Execute {cmd}. If it contains a command that splits a window,
|
Execute {cmd}. If it contains a command that splits a window,
|
||||||
@@ -530,6 +537,10 @@ CTRL-W = Make all windows (almost) equally high and wide, but use
|
|||||||
'winheight' and 'winwidth' for the current window.
|
'winheight' and 'winwidth' for the current window.
|
||||||
Windows with 'winfixheight' set keep their height and windows
|
Windows with 'winfixheight' set keep their height and windows
|
||||||
with 'winfixwidth' set keep their width.
|
with 'winfixwidth' set keep their width.
|
||||||
|
To equalize only vertically (make window equally high) use
|
||||||
|
`vertical wincmd =`
|
||||||
|
To equalize only horizontally (make window equally wide) use
|
||||||
|
`horizontal wincmd =`
|
||||||
|
|
||||||
:res[ize] -N *:res* *:resize* *CTRL-W_-*
|
:res[ize] -N *:res* *:resize* *CTRL-W_-*
|
||||||
CTRL-W - Decrease current window height by N (default 1).
|
CTRL-W - Decrease current window height by N (default 1).
|
||||||
|
@@ -1140,6 +1140,12 @@ module.cmds = {
|
|||||||
addr_type='ADDR_NONE',
|
addr_type='ADDR_NONE',
|
||||||
func='ex_history',
|
func='ex_history',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
command='horizontal',
|
||||||
|
flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
|
||||||
|
addr_type='ADDR_NONE',
|
||||||
|
func='ex_wrongmodifier',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
command='insert',
|
command='insert',
|
||||||
flags=bit.bor(BANG, RANGE, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
|
flags=bit.bor(BANG, RANGE, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
|
||||||
|
@@ -2438,8 +2438,12 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, cmdmod_T *cmod, bool
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ":hide" and ":hide | cmd" are not modifiers
|
|
||||||
case 'h':
|
case 'h':
|
||||||
|
if (checkforcmd(&eap->cmd, "horizontal", 3)) {
|
||||||
|
cmod->cmod_split |= WSP_HOR;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// ":hide" and ":hide | cmd" are not modifiers
|
||||||
if (p != eap->cmd || !checkforcmd(&p, "hide", 3)
|
if (p != eap->cmd || !checkforcmd(&p, "hide", 3)
|
||||||
|| *p == NUL || ends_excmd(*p)) {
|
|| *p == NUL || ends_excmd(*p)) {
|
||||||
break;
|
break;
|
||||||
|
@@ -343,6 +343,46 @@ func Test_window_height()
|
|||||||
bw Xa Xb Xc
|
bw Xa Xb Xc
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_wincmd_equal()
|
||||||
|
edit Xone
|
||||||
|
below split Xtwo
|
||||||
|
rightbelow vsplit Xthree
|
||||||
|
call assert_equal('Xone', bufname(winbufnr(1)))
|
||||||
|
call assert_equal('Xtwo', bufname(winbufnr(2)))
|
||||||
|
call assert_equal('Xthree', bufname(winbufnr(3)))
|
||||||
|
|
||||||
|
" Xone and Xtwo should be about the same height
|
||||||
|
let [wh1, wh2] = [winheight(1), winheight(2)]
|
||||||
|
call assert_inrange(wh1 - 1, wh1 + 1, wh2)
|
||||||
|
" Xtwo and Xthree should be about the same width
|
||||||
|
let [ww2, ww3] = [winwidth(2), winwidth(3)]
|
||||||
|
call assert_inrange(ww2 - 1, ww2 + 1, ww3)
|
||||||
|
|
||||||
|
1wincmd w
|
||||||
|
10wincmd _
|
||||||
|
2wincmd w
|
||||||
|
20wincmd |
|
||||||
|
call assert_equal(10, winheight(1))
|
||||||
|
call assert_equal(20, winwidth(2))
|
||||||
|
|
||||||
|
" equalizing horizontally doesn't change the heights
|
||||||
|
hor wincmd =
|
||||||
|
call assert_equal(10, winheight(1))
|
||||||
|
let [ww2, ww3] = [winwidth(2), winwidth(3)]
|
||||||
|
call assert_inrange(ww2 - 1, ww2 + 1, ww3)
|
||||||
|
|
||||||
|
2wincmd w
|
||||||
|
20wincmd |
|
||||||
|
call assert_equal(20, winwidth(2))
|
||||||
|
" equalizing vertically doesn't change the widths
|
||||||
|
vert wincmd =
|
||||||
|
call assert_equal(20, winwidth(2))
|
||||||
|
let [wh1, wh2] = [winheight(1), winheight(2)]
|
||||||
|
call assert_inrange(wh1 - 1, wh1 + 1, wh2)
|
||||||
|
|
||||||
|
bwipe Xone Xtwo Xthree
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_window_width()
|
func Test_window_width()
|
||||||
e Xa
|
e Xa
|
||||||
vsplit Xb
|
vsplit Xb
|
||||||
|
@@ -417,10 +417,12 @@ newwindow:
|
|||||||
| ((nchar == 'H' || nchar == 'K') ? WSP_TOP : WSP_BOT));
|
| ((nchar == 'H' || nchar == 'K') ? WSP_TOP : WSP_BOT));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// make all windows the same height
|
// make all windows the same width and/or height
|
||||||
case '=':
|
case '=': {
|
||||||
win_equal(NULL, false, 'b');
|
int mod = cmdmod.cmod_split & (WSP_VERT | WSP_HOR);
|
||||||
|
win_equal(NULL, false, mod == WSP_VERT ? 'v' : mod == WSP_HOR ? 'h' : 'b');
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// increase current window height
|
// increase current window height
|
||||||
case '+':
|
case '+':
|
||||||
|
@@ -17,14 +17,15 @@
|
|||||||
#define FNAME_UNESC 32 // remove backslashes used for escaping
|
#define FNAME_UNESC 32 // remove backslashes used for escaping
|
||||||
|
|
||||||
// arguments for win_split()
|
// arguments for win_split()
|
||||||
#define WSP_ROOM 1 // require enough room
|
#define WSP_ROOM 0x01 // require enough room
|
||||||
#define WSP_VERT 2 // split vertically
|
#define WSP_VERT 0x02 // split/equalize vertically
|
||||||
#define WSP_TOP 4 // window at top-left of shell
|
#define WSP_HOR 0x04 // equalize horizontally
|
||||||
#define WSP_BOT 8 // window at bottom-right of shell
|
#define WSP_TOP 0x08 // window at top-left of shell
|
||||||
#define WSP_HELP 16 // creating the help window
|
#define WSP_BOT 0x10 // window at bottom-right of shell
|
||||||
#define WSP_BELOW 32 // put new window below/right
|
#define WSP_HELP 0x20 // creating the help window
|
||||||
#define WSP_ABOVE 64 // put new window above/left
|
#define WSP_BELOW 0x40 // put new window below/right
|
||||||
#define WSP_NEWLOC 128 // don't copy location list
|
#define WSP_ABOVE 0x80 // put new window above/left
|
||||||
|
#define WSP_NEWLOC 0x100 // don't copy location list
|
||||||
|
|
||||||
// Minimum screen size
|
// Minimum screen size
|
||||||
#define MIN_COLUMNS 12 // minimal columns for screen
|
#define MIN_COLUMNS 12 // minimal columns for screen
|
||||||
|
Reference in New Issue
Block a user