我正在使用emacs,我发现有时候我将2个文件分成2个窗口.
例如:我使用打开1个文件 C-x C-f file1.c RET
我将框架分成两个窗口: C-x 3
然后我打开另一个文件 C-x C-f file2.c RET
所以我有2个文件:
窗口1(左) file1.c
窗口2(右) file2.c
我想知道是否有任何组合交换文件?通常情况下,当我有2个窗口时,我喜欢在左侧窗口上工作.我知道我可以轻松C-x o地将光标移动到右侧窗口.
但是,我只是想知道我是否可以交换文件,以便file2.c
在左侧窗口中并且file1.c
在右侧窗口中?
我为此使用buffer-move.现在,如果您正在处理左侧的缓冲区,则调用"buf-move-right"会将其与右侧的缓冲区进行交换.我想这就是你想要的.
的转置帧库提供了相当全面的函数集用于翻转或以帧旋转窗口安排.
M-x flop-frame
RET 做这个特殊问题需要什么.
以下图表来自库(及其EmacsWiki页面)中的注释:
‘transpose-frame’ … Swap x-direction and y-direction +------------+------------+ +----------------+--------+ | | B | | A | | | A +------------+ | | | | | C | => +--------+-------+ D | +------------+------------+ | B | C | | | D | | | | | +-------------------------+ +--------+-------+--------+ ‘flip-frame’ … Flip vertically +------------+------------+ +------------+------------+ | | B | | D | | A +------------+ +------------+------------+ | | C | => | | C | +------------+------------+ | A +------------+ | D | | | B | +-------------------------+ +------------+------------+ ‘flop-frame’ … Flop horizontally +------------+------------+ +------------+------------+ | | B | | B | | | A +------------+ +------------+ A | | | C | => | C | | +------------+------------+ +------------+------------+ | D | | D | +-------------------------+ +-------------------------+ ‘rotate-frame’ … Rotate 180 degrees +------------+------------+ +-------------------------+ | | B | | D | | A +------------+ +------------+------------+ | | C | => | C | | +------------+------------+ +------------+ A | | D | | B | | +-------------------------+ +------------+------------+ ‘rotate-frame-clockwise’ … Rotate 90 degrees clockwise +------------+------------+ +-------+-----------------+ | | B | | | A | | A +------------+ | | | | | C | => | D +--------+--------+ +------------+------------+ | | B | C | | D | | | | | +-------------------------+ +-------+--------+--------+ ‘rotate-frame-anti-clockwise’ … Rotate 90 degrees anti-clockwise +------------+------------+ +--------+--------+-------+ | | B | | B | C | | | A +------------+ | | | | | | C | => +--------+--------+ D | +------------+------------+ | A | | | D | | | | +-------------------------+ +-----------------+-------+
在Emacs 26.1 NEWS文件中,有以下条目:
+++ *** New command 'window-swap-states' swaps the states of two live windows.
哪个似乎提供类似的功能,crux-transpose-windows
但也可以做一些高度/宽度换位?
如果您使用Prelude,可以使用C-c s
(prelude-swap-windows
).来自Prelude文档:
C-c s
运行命令crux-swap-windows
(在发现prelude-mode-map
),这是一个别名crux-transpose-windows
在crux.el.
我不知道有任何内置函数这样做.
然而,为了做到这一点,鞭挞一些elisp似乎并不太难.魔鬼虽然在细节.
(defun swap-buffers-in-windows () "Put the buffer from the selected window in next window, and vice versa" (interactive) (let* ((this (selected-window)) (other (next-window)) (this-buffer (window-buffer this)) (other-buffer (window-buffer other))) (set-window-buffer other this-buffer) (set-window-buffer this other-buffer) ) )
值得注意的是,对于插入符号的最终位置,这可能不是您所希望的.但是,你首先必须说出你想要的东西:p