在 emacs 中如何将窗口的垂直分割改为水平分割

文章目录

<2022-08-25 周四>

emacs中如何将窗口的垂直分割改为水平分割

emacs没有原生支持,所以抄了一个函数,如下:

emacs-lisp 复制代码
;;; https://www.emacswiki.org/emacs/ToggleWindowSplit
(defun toggle-window-split ()
  (interactive)
  (if (= (count-windows) 2)
      (let* ((this-win-buffer (window-buffer))
             (next-win-buffer (window-buffer (next-window)))
             (this-win-edges (window-edges (selected-window)))
             (next-win-edges (window-edges (next-window)))
             (this-win-2nd (not (and (<= (car this-win-edges)
                                         (car next-win-edges))
                                     (<= (cadr this-win-edges)
                                         (cadr next-win-edges)))))
             (splitter
              (if (= (car this-win-edges)
                     (car (window-edges (next-window))))
                  'split-window-horizontally
                'split-window-vertically)))
        (delete-other-windows)
        (let ((first-win (other-window 1)))
          (funcall splitter)
          (if this-win-2nd
              (other-window 1))
          (set-window-buffer (selected-window) this-win-buffer)
          (set-window-buffer (next-window) next-win-buffer)
          (if this-win-2nd
              (other-window 1))))))

emacs如何将两个窗口的内容交换?调用M-x window-swap-states即可。

相关推荐
Leon Cheng4 小时前
Vue3 + Monaco Editor 实现智能变量编辑器:隐藏花括号的魔法
编辑器
ONLYOFFICE8 小时前
ONLYOFFICE 桌面编辑器正式成为 ShaniOS 默认办公套件
linux·编辑器·github·onlyoffice
zhyongrui9 小时前
SnipTrip:贴纸画布编辑器与“光晕动效”的交互细节
编辑器·交互
山峰哥9 小时前
SQL调优实战:从索引到执行计划的深度优化指南
大数据·开发语言·数据库·sql·编辑器·深度优先
山峰哥1 天前
破解SQL性能瓶颈:索引优化核心策略
大数据·数据库·sql·oracle·编辑器·深度优先·数据库架构
何亚告1 天前
VScode引入claude+deepseek
ide·vscode·编辑器
芝芝葡萄1 天前
VsCode中使用Codex
前端·ide·vscode·编辑器·ai编程
GuiltyFet1 天前
CKEditor副本编辑器CVE-2021-33829漏洞复现
安全·编辑器
历程里程碑1 天前
Linux 9:GCC编译全流程详解
linux·运维·服务器·c语言·笔记·编辑器·vim