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

相关推荐
电子科技圈4 小时前
IAR全面支持国科环宇AS32X系列RISC-V车规MCU
人工智能·嵌入式硬件·mcu·编辑器
安冬的码畜日常1 天前
【工欲善其事】巧用 Sublime Text 生成带格式的 HTML 片段
编辑器·html·typora·sublime text·代码片段·snippet
风竹夜1 天前
记录一次病毒启动脚本
c++·windows·安全·编辑器·batch·福昕阅读器
遮天华月1 天前
VS与VSCode的区别
ide·vscode·编辑器
佚明zj2 天前
VIM的使用总结
linux·编辑器·vim
四次元的lucly2 天前
vscode 内网不联网如何导入vscode插件
ide·vscode·编辑器
z.q.xiao2 天前
VScode 自定义代码配色方案
ide·vscode·编辑器
Susu_afmx2 天前
pdf怎么编辑修改内容?详细介绍6款pdf编辑器功能
windows·pdf·编辑器·电脑·笔记本电脑·pdf编辑器
GEEKVIP2 天前
适用于 Windows 10 的最佳 PDF 编辑器列表,可帮助更改 PDF 文件。
windows·macos·智能手机·pdf·编辑器·excel·iphone
觉醒法师3 天前
VSCode开发Vue3+TS项目中遇到各种波浪线(诊断信息)
前端·ide·vue.js·vscode·typescript·编辑器