在 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即可。

相关推荐
山峰哥3 小时前
数据库工程与查询优化案例深度复盘‌
数据库·sql·oracle·编辑器·深度优先·宽度优先
Masimaro6 小时前
《elisp 每日一练》——Window 树与布局状态恢复
emacs
javgo.cn11 小时前
Markweave:开源 Markdown-first WYSIWYG 编辑器
开源·编辑器
YZJenny1 天前
在服务器上安装使用code-server(Web 版 VS Code)
ide·vscode·编辑器
zhangfeng11331 天前
nano vim 有没有快速编辑的 方式 比如鼠标选择 ,然后快速修改 替换
编辑器·vim
salestina1 天前
vscode迁移扩展目录
ide·vscode·编辑器
山峰哥1 天前
数据库工程:Explain执行计划对比调优实战‌
大数据·数据库·sql·编辑器·深度优先
Molesidy2 天前
【Embedded Development】基于VSCode+IAR插件的IAR工程开发环境的搭建
ide·vscode·编辑器
典典分享指南2 天前
Windows 自动化踩坑实录
python·intellij-idea·pyqt·emacs·visual studio
泛凡(Linyongui)2 天前
告别原始编辑器:VS Code 搭建 中微CMS IDE 编译环境完整指南
ide·单片机·编辑器