ChatGPT解决这个技术问题 Extra ChatGPT

emacs, unsplit a particular window split

I often want to unsplit window as follows:

+--------------+-------------+             +--------------+-------------+
|              |             |             |              |             |
|              |             |             |              |             |
|              |             |             |              |             |
+--------------+             |     -->     |              |             |
|              |             |             |              |             |
|              |             |             |              |             |
|              |             |             |              |             |
+--------------+-------------+             +--------------+-------------+



+--------------+--------------+            +-----------------------------+
|              |              |            |                             |
|              |              |            |                             |
|              |              |            |                             |
+--------------+--------------+    -->     +-----------------------------+
|                             |            |                             |
|                             |            |                             |
|                             |            |                             |
+-----------------------------+            +-----------------------------+

Currently, I start with ctrl-x 1 and then split vertically/horizontally. but my real qustion is how can one remove a particular window split with out disturbing the other window structure? Is there any elisp function in built?

my bad, copy pasted from my emacs, how can i edit the question?
Just click the edit link underneath the tags. I've done this for you this time around. Also, avoid tab characters in the middle of a line. It plays havoc with formatting.
Wow, Marcelo Thanks for that. corrected within no time

p
phils

You can use the C-x0 key combination to delete the current window.


Thanks, that gave me the answer. To be precise, C-u C-x 0 resulted the effect I wanted.
This should also be bound to C-w q as per vim default behaviour
I've been using Emacs for 30 years and never noticed this feature!
C-x 0 merges the freed up space with whereever it came from though, but if I want to merge with a specific other window, C-x 0 won't do the job.
p
phils

Rémi's answer is what you're looking for, but winner mode is also extremely useful for getting you back to previous window configurations after making any arbitrary changes (such as restoring those multiple-splits after typing C-x1).

You can enable it in your init file with:

(winner-mode 1) ;"C-c <left>" and "C-c <right>" undo and re-do window changes.

Also see: http://www.emacswiki.org/emacs/CategoryWindows