当我打开一个文件时,我想打开另一个文件,窗口垂直分割。在vim中,这是:vs filename
。在emacs中,我认为这是C-X 3
,C-X o
,C-X C-F
,filename
。我们可以缩短它吗?
答案 0 :(得分:5)
C-h f find-file-other-window RET
默认情况下绑定到C-x 4 f
,但您可以使用C-x f
将其重新映射到global-set-key
。
答案 1 :(得分:0)
我认为仅使用find-file-other-window
并不完全符合您的要求。它使用display-buffer
,它不仅仅是垂直分割,而是试图找到一个显示新缓冲区的位置。你可以做这样的事情
(defun find-file-split-horizontally()
(interactive)
(flet ; temporary change
; display-buffer function to
; our needs
((display-buffer (buffer-or-name &optional not-this-window frame)
(select-window (split-window-horizontally)) ; select newly created window
(switch-to-buffer buffer-or-name)))
(call-interactively 'find-file-other-window)))
(defun switch-to-buffer-split-horizontally()
(interactive)
(flet
((display-buffer (buffer-or-name &optional not-this-window frame)
(select-window (split-window-horizontally))
(switch-to-buffer buffer-or-name)))
(call-interactively
;; use only one of these
'ido-switch-buffer-other-window
;;'switch-to-buffer-other-window
)))
这将始终尝试水平拆分当前缓冲区。