我正在使用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在右侧窗口中?
Raj*_*raj 86
我为此使用buffer-move.现在,如果您正在处理左侧的缓冲区,则调用"buf-move-right"会将其与右侧的缓冲区进行交换.我想这就是你想要的.
phi*_*ils 32
的转置帧库提供了相当全面的函数集用于翻转或以帧旋转窗口安排.
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 | | | |
+-------------------------+ +-----------------+-------+
Run Code Online (Sandbox Code Playgroud)
dgt*_*zed 21
在Emacs 26.1 NEWS文件中,有以下条目:
+++
*** New command 'window-swap-states' swaps the states of two live
windows.
Run Code Online (Sandbox Code Playgroud)
哪个似乎提供类似的功能,crux-transpose-windows但也可以做一些高度/宽度换位?
Bah*_*bar 11
我不知道有任何内置函数这样做.
然而,为了做到这一点,鞭挞一些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)
)
)
Run Code Online (Sandbox Code Playgroud)
值得注意的是,对于插入符号的最终位置,这可能不是您所希望的.但是,你首先必须说出你想要的东西:p
Raj*_*boy 11
作为当前的 emacs 29 版本。我们有windmove,就像交换窗口的魔法一样。
windmove-swap-states-right
windmove-swap-states-up
windmove-swap-states-left
windmove-swap-states-down