在emacs中打开2个文件时,如何让它们并排显示?
有时我从命令行启动带有 2 个文件的 emacs,如下所示:
emacs foo.txt bar.txt
这将打开 emacs 窗口,垂直分割:
foo.txt
-------
bar.txt
如何编辑我的 .emacs 文件,以便它们并排显示,如下所示?:
|
foo.txt | bar.txt
|
编辑:为了澄清,我知道如何在 emacs 启动后实现这一点(Mx 0、Mx 3,然后在右侧窗口中重新访问 bar.txt)。我只是希望 emacs 在启动时默认并排拆分,所以我不必这样做。
Sometimes I launch emacs from the command line with 2 files, as follows:
emacs foo.txt bar.txt
This opens the emacs window, split vertically:
foo.txt
-------
bar.txt
How can I edit my .emacs file so that they show up side-by-side, like this?:
|
foo.txt | bar.txt
|
EDIT: To clarify, I know how to make this happen after emacs has launched (M-x 0, M-x 3, then re-visit bar.txt in the right window). I just want emacs to split side-by-side by default when I launch it, so I don't have to.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
这是一个将一对垂直窗口更改为一对水平窗口的函数:
要在启动时自动执行此操作,请将此函数添加到
emacs-startup-hook
中:Here's a function that will change a pair of vertical windows to a pair of horizontal windows:
To do this automatically on startup, add this function to
emacs-startup-hook
:以下内容(添加到您的 .emacs 中)使窗口分割默认结果在并排缓冲区中(而不是一个在另一个缓冲区之上):
当您运行诸如
find-file 之类的命令时,此默认值也将适用-其他窗口
(Ctrlx4f)。(另一方面,要手动拆分窗口以获得两个并排缓冲区,请考虑 这个答案)。
The following (to add to your .emacs) makes the window splitting default result in side-by-side buffers (rather than one above the other):
This default will also apply when you run a command such as
find-file-other-window
(Ctrlx4f).(On the other hand, to manually split your window to get two side-by-side buffers, consider this answer).
这对我来说效果很好。使用命令行中的 -f 函数名称,让它根据您的喜好设置您的 emacs 分屏工作区。这为我提供了一个 2 x 2 的财务文件网格,我每天都会更新这些文件,并将光标设置在最后的相应窗口上。我将其保存到 .bashrc 作为别名,这样我就可以用一个命令(doc_financial)将其调出。
This has worked well for me. Use the -f function-name from the command-line to have it set up your emacs split-screen workspace as you like. This gives me a 2 x 2 grid of my financial files that I update every day and sets the cursor on the appropriate window at the end. I save this to .bashrc as an alias so I can pull it up with one command (doc_financial).
使用
Mx split-window-horizontally
或Ctrl-x 3
。Use
M-x split-window-horizontally
orCtrl-x 3
.Ctrl -x 2
分割窗口,
缓冲区 1 上方和下方(上方)
缓冲区 2(下)
Ctrl -x 3
分割窗口,并排
缓冲区 1(左)|缓冲区 2(右)
CMv
滚动其他窗口
Ctrl -x 2
Split window, above and below
Buffer 1 (above)
Buffer 2 (Below)
Ctrl -x 3
Split window, Side by Side
Buffer 1(left) | Buffer 2 (right)
C-M-v
Scroll other window
使用水平分割窗口。
Use split-window-horizontally.