emacs 中缓冲区分割后如何切换焦点?
我希望在分割窗口(Cx 3
或 Cx 2
)后能够自动到达新打开的缓冲区(当前缓冲区以外的缓冲区)中的光标。我怎样才能实现这种行为?
I would like that after splitting the window (C-x 3
or C-x 2
) to be able to automatically get to cursor in the new opened buffer (the other than the current). How can I achieve this behavior ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以使用
Cx o
在缓冲区之间切换。至于自动执行此操作,我认为没有现有的命令。You can switch between buffers with
C-x o
. As to do that automatically I don't think there is an existing command for that.您可以这样做:
在 Emacs 24.3.1 中,如果您将参数
1
更改为0
,它就会起作用。You can do it like this:
In Emacs 24.3.1 it works if you change the argument
1
for0
.!!!不要使用这个答案!!! - 正如评论中指出的,建议
split-window
可能会导致不良的副作用。我推荐 Bozhidar Batsov 的答案。
将以下内容放入您的 .emacs 文件中:
!!!DO NOT USE THIS ANSWER!!! -- as pointed out in the comments, advising
split-window
can lead to undesired side-effects.I recommend Bozhidar Batsov's answer instead.
Put the following in your .emacs file:
除了使用 Cx 2 或 Cx 3 手动分割帧之外,缓冲区有时也会自动“弹出”。默认情况下,这些也未被选中/激活。
这可以通过更改用于分割窗口的函数来解决。默认情况下,它设置为 split-window-sensible,但您可以将其设置为您自己的函数,该函数调用 split-window-sensible,然后选择缓冲区。
但不幸的是,当您在迷你缓冲区中点击 TAB 时,这会产生选择
*Completions*
缓冲区的副作用。因此,值得检查一下迷你缓冲区是否处于活动状态并且在这种情况下未进行切换。我敢打赌还有其他类似的不良情况。当我找到它们时,我会尝试更新这篇文章。(适用于 Emacs 24.5.1。)
As well as splitting the frame manually with C-x 2 or C-x 3, buffers are also automatically "popped-up" some times. These are also not selected/active by default.
This can be fixed by changing the function used to split a window. It's set to
split-window-sensibly
by default, but you can set it to your own function that callssplit-window-sensibly
and then selects the buffer.Unfortunately, though, this has the side-effect of selecting the
*Completions*
buffer when you hit TAB in the minibuffer. So, it's worth checking to see if the minibuffer is active and not switching in this case. I'd bet there are other such undesirable scenarios as well. I'll try to update this post as and when I find them.(Works with Emacs 24.5.1.)
我的想法是,当您想要在
split-window
之后跟随窗口时,它具有相同的缓冲区,如以下代码所示:简单
My thought of when you would want to follow the window after a
split-window
was when it had the same buffer like in the following code:Simple
Cx o 将帮助您切换到“其他”缓冲区。
C-x o will help you switch to the "other" buffer.