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

相关推荐
yqcoder2 小时前
vscode 中快捷生成模板快捷键
ide·vscode·编辑器
正经教主6 小时前
【菜鸟飞】通过vsCode用python访问deepseek-r1等模型
ide·vscode·编辑器·ai编程
ivwdcwso10 小时前
Vim忍者速成秘卷:让你的键盘冒出残影の奥义
linux·编辑器·vim·程序员忍道·终端美学·效率革命
YEAH!启动!11 小时前
android 调用wps打开文档并感知保存事件
android·编辑器·word·excel·wps·ppt
与光同尘 大道至简1 天前
Markdown 语法入门指南(VSCode 版)
ide·vscode·编辑器
simplesin1 天前
yarn安装及配置,cmd可以查看yarn版本号但是vscode无法查看且运行问题
ide·vscode·编辑器
不羁。。1 天前
【操作系统安全】任务1:操作系统部署
开发语言·windows·编辑器
zhixingheyi_tian1 天前
PDF Reader
编辑器
渣檬Charman1 天前
Linux基础开发工具—vim
linux·编辑器·vim
web组态软件1 天前
web组态可视化编辑器
大数据·前端·物联网·低代码·数学建模·编辑器