如何更改分屏 emacs 窗口的大小?
我将 emacs 水平分割 - 在顶部我正在编辑 Perl 代码,底部是 shell。默认情况下,emacs 使两个窗口大小相等,但我希望 shell 缓冲区更小(也许是一半大小?)。我想知道我怎样才能做到这一点。
I have emacs split horizontally - on top I'm editing Perl code, the bottom is the shell. By default emacs makes the two windows equal in size, but I'd like the shell buffer smaller (maybe half the size?). I was wondering how I could do that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
使用鼠标,您可以拖动窗口大小。
单击模式线上非“活动”的任意位置(缓冲区名称是安全的,或右侧任何未使用的区域),然后可以向上或向下拖动。
左右拖动需要非常精确地单击两条模式线的连接点。
Cx - (
shrink-window-if-larger-than-buffer
) 将缩小窗口以适应其内容。Cx + (
balance-windows
) 将使窗口具有相同的高度和宽度。Cx ^ (
enlarge-window
) 将高度增加 1 行或前缀 arg 值。负参数会缩小窗口。例如C-- C-1 C-6 Cx ^ 缩小 16 行,Cu 也是如此 - 1 6 Cx ^。(
shrink-window
没有默认绑定。)Cx }(
enlarge-window-horizontally
) 水平方向同样如此。Cx { (
shrink-window-horizontally
) 也默认绑定。使用
repeat
执行这些命令之一(Cx z启动,只需z继续重复)可以很容易地获得您想要的确切尺寸。如果您经常想要使用特定值执行此操作,您可以录制键盘宏来执行此操作,或使用类似
(global-set-key (kbd "Cc v") (kbd "Cu - 1 6 Cx ^"))
或者这样:
(global-set-key (kbd "Cc v") (kbd "Cx o Cx 2 Cx 0 Cu - 1 Cx o"))
这是一个小黑客,所以这会更好:
切向,我也喜欢
winner-mode
,它可以让您使用 Cc 反复“撤消”对窗口配置的任何更改 left(无论更改是窗口的大小/数量/排列,或者只是显示哪个缓冲区)。 抄送 右返回到最新的配置。使用(winner-mode 1)
进行全局设置With the mouse, you can drag the window sizes around.
Click anywhere on the mode line that is not otherwise 'active' (the buffer name is safe, or any unused area to the right hand side), and you can drag up or down.
Side-to-side dragging requires a very precise click on the spot where the two mode lines join.
C-x - (
shrink-window-if-larger-than-buffer
) will shrink a window to fit its content.C-x + (
balance-windows
) will make windows the same heights and widths.C-x ^ (
enlarge-window
) increases the height by 1 line, or the prefix arg value. A negative arg shrinks the window. e.g. C-- C-1 C-6 C-x ^ shrinks by 16 rows, as does C-u - 1 6 C-x ^.(There is no default binding for
shrink-window
.)C-x } (
enlarge-window-horizontally
) does likewise, horizontally.C-x { (
shrink-window-horizontally
) is also bound by default.Following one of these commands with
repeat
(C-x z to initiate, and just z for continued repetition) makes it pretty easy to get to the exact size you want.If you regularly want to do this with a specific value, you could record a keyboard macro to do it, or use something like
(global-set-key (kbd "C-c v") (kbd "C-u - 1 6 C-x ^"))
Or this:
(global-set-key (kbd "C-c v") (kbd "C-x o C-x 2 C-x 0 C-u - 1 C-x o"))
Which is a smidgen hacky, so this would be better:
Tangentially, I also love
winner-mode
which lets you repeatedly 'undo' any changes to window configurations with C-c left (whether the change is the size/number/arrangement of the windows, or just which buffer is displayed). C-c right returns you to the most recent configuration. Set it globally with(winner-mode 1)
我将这些放入我的
.emacs
中:I put these in my
.emacs
:让我们尝试使用 emacs 帮助文档。
Ch a
然后输入“放大”或“窗口”
您会找到您想要的内容。
享受!
let's try to use emacs help document.
C-h a
Then type "enlarge" or "window"
You will find what you want.
Enjoy!
Cx o
到您想要扩大其大小的窗口。从那里,Cx ^
展开它。C-x o
to the window whose size you want expanded. From there,C-x ^
to expand it.Cx ^
接受正数和负数值参数。特别是,如果您想将光标当前所在的窗口缩小四行,可以按Cu -4 Cx ^
。C-x ^
takes positive and negative numerical arguments. In particular, if you would like to shrink the window where your cursor currently is by four lines, you can pressC-u -4 C-x ^
.这不是您正在寻找的确切答案,但我在查找 spacemacs 中的功能时偶然发现了这个问题,因此为了完整起见,我将写下我的答案。
该选项是使用
+ w + .
(适用于普通 spacemacs)这会打开一个瞬态窗口,您可以在其中使用
[]{}
在粒度级别上调整大小。不需要 Cx 或鼠标...
This is not the exact answer you're looking for, but I stumbled upon this question when looking out for the functionality in
spacemacs
, so I'll write my answer just for completeness' sake.The option is to use
<SPC> + w + .
(it works in vanilla spacemacs)This opens up a transient window where one can use
[]{}
to resize at a granular level.There's no need for C-x or Mouse...
我也有同样的问题。这是我的解决方案。
首先我定义一个新函数:
例如,我想在缓冲区中运行方案,所以我重写它。
这是定义,其中包含前面定义的函数:
所以现在当我输入:Mx run-scheme-here 时,缓冲区大小被调整!
这是我的配置文件,希望这会有所帮助。 https://github.com/judevc/dotfiles/ blob/master/.emacs.d/scheme-conf.el
I got the same question. Here is my solution.
First I define a new function:
For example, I want to run-scheme in a buffer, So I rewrite it.
And here is the definition, with the function defined earlier:
So now when I enter: M-x run-scheme-here, the buffer is resized!
And here is my config file, hoping this will help. https://github.com/judevc/dotfiles/blob/master/.emacs.d/scheme-conf.el