How to swap the buffers in 2 windows emacs

前端 未结 8 1432
情深已故
情深已故 2020-12-22 20:51

I am using emacs I find that sometimes I have 2 files separated into 2 windows.

For example: I open 1 file using C-x C-f file1.c RET

and I split t

8条回答
  •  时光取名叫无心
    2020-12-22 21:12

    The transpose-frame library provides a pretty comprehensive set of functions for flipping or rotating the window arrangements in frames.

    M-x flop-frame RET does what this particular question needs.

    The following diagrams are from the commentary in the library (and its EmacsWiki page):

    ‘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            |      |                 |       |
           +-------------------------+      +-----------------+-------+
    

提交回复
热议问题