您可以使用前缀参数告诉 Emacs 给两个窗口中的每一个提供多少行。
参见:C-hk C-x2
或 C-hf split-window-below RET
如果可选参数 SIZE 被省略或为零,则两个窗口都获得
相同的高度,或接近它。如果 SIZE 为正,则上
(选定)窗口获取 SIZE 行。如果 SIZE 为负,则
下部(新)窗口获得 -SIZE 行。
所以你可以给上面的窗口 20 行和下面的窗口剩下的: C-u 20 C-x2
(或M-2M-0C-x2等...)
你可以给下面的窗口 10 行和上面的窗口剩下的: C-u -10 C-x2
(或M--M-1M-0Cx2等...)
查看How to change size of split screen emacs windows?,了解拆分后修改窗口大小的多种方法。
编辑:
你可以使用下面的函数来做你想做的事:
(defun my-split-window-below (&optional arg)
"Split the current window 70/30 rather than 50/50.
A single-digit prefix argument gives the top window arg*10%."
(interactive "P")
(let ((proportion (* (or arg 7) 0.1)))
(split-window-below (round (* proportion (window-height))))))
(global-set-key (kbd "C-c x 2") 'my-split-window-below)
默认比率为 70/30,但您可以提供一位数前缀参数以 10% 的增量指定顶部窗口的大小。
如果您将此命令绑定到 Cx2 则 C-9Cx2 kbd> 会给顶部窗口 90% 和底部 10%。
编辑 2: 我最终使用了它的一个变体作为我自己的 C-x2 绑定。此版本默认为正常的 50/50 拆分,但提供与其他函数相同的前缀 arg 功能,以防我想要不同的东西。
(defun my-split-window-below (&optional arg)
"Split the current window 50/50 by default.
A single-digit prefix argument gives the top window ARG * 10%
of the available lines."
(interactive "P")
(let* ((proportion (and arg (* arg 0.1)))
(size (and proportion (round (* proportion (window-height))))))
(split-window-below size)))