Problem Description
In GNU Emacs, switching windows (Window) is a troublesome thing ( 20.3 Using Other Windows ), because we want to press a shortcut key to switch directly to a specific window (Window) instead of a shortcut key combination.
This note will record: In GNU Emacs, the method of quickly switching between windows (Window).
Solution
We have two options: EmacsWiki: Numbered Windows and EmacsWiki: Window Numbering Mode plugin
Numbered Windows
window-number-mode is an interactive compiled Lisp function in ‘window-number.el’.
nikolas/window-number: Select windows by M-1, M-2, etc in Emacs
Window Numbering Mode
window-numbering-mode is an interactive autoloaded compiled Lisp function in ‘window-numbering.el’.
nschum/window-numbering.el: Emacs: Numbered window shortcuts
Our choice of plugin
We use the window-numbering.el plug-in, which is turned on by Mx window-numbering-mode. It will display a number at the beginning of the Mode Line to indicate the serial number of the current window, and then use M-<number> to switch the window.
There is no special reason for the selection, it may be because we have been using the Window Numbering Mode plug-in, and the numbered Windows display number style and position do not conform to our aesthetics :-)
Our configuration parameters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Window Number ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (require 'window-number) ;; (window-number-mode 1) (require 'window-numbering) (defun window-numbering-get-number-string (&optional window) (let ((s (int-to-string (window-numbering-get-number window)))) (propertize (concat " " s " ") 'face 'window-numbering-face))) (window-numbering-mode 1)
We redefine the window-numbering-get-number-string function so that the left and right sides of the number displayed on the Mode Line are spaces, which will be wider and more conspicuous.
Copy the above function definition (defun) to the window-numbering.el file, and modify s to (concat "" s "") to add spaces. If you want to understand these things, you need to learn Emacs Lisp programming.
references
WikiNotes/Quick Switch Window (Window)
EmacsWiki: Numbered Windows
EmacsWiki: Window Numbering Mode