4

I'm currently in mode: C-x 2

Normally, I don't care much about vertical splitting. However, I'm coding on a 13" display, which makes vertical space rather precious.

I would like some setup where when I do C-x 2, my window is not split 50/50, but rather 70/30 [this way I can send the repl to the bottom portion of the screen, and stll see quite a bit of code.]

C-h a vertical split

brings up:

split-window-vertically, table-split-call-vertically

However, I suspect there is some parameter that changes / controls the split ratio.

What emacs option tells my computer to split 70/30 rather than 50/50?

Thanks!

4

1 回答 1

5

您可以使用前缀参数告诉 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-0C-x2,等等......)

请参阅如何更改分屏 emacs 窗口的大小?有很多方法可以在拆分后修改窗口的大小。

编辑:

您可以使用以下功能来做您想做的事:

(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% 的增量指定顶部窗口的大小。

如果将此命令绑定到C-x2thenC-9C-x2将给顶部窗口 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)))
于 2012-04-20T04:42:51.637 回答