Moving focus and buffer between Emacs window
focus and buffer between Emacs window :en:emacs:window:buffer:move:
Please read the excellent article Moving between Emacs windows for basic setup.
Here is my summary of that article:
- you can use
windmove.el(embedded in Emacs). Its hotkey is Shift+Arrow
switch-window.el is great. The default hot key is
I also use other packages which is more efficient.
window-numbering.el is great. It uses hot key
M-number to switch window (for example,
M-3 to select window with number 3). So I can press only one key to switch window. Besides, it has some extra features like
M-0 to jump to the minibuffer.
Here is my configuration for
(require 'window-numbering) ;; highlight the window number in pink color (custom-set-faces '(window-numbering-face ((t (:foreground "DeepPink" :underline "DeepPink" :weight bold))))) (window-numbering-mode 1)
Evil is a vim-emulation. It use vim's keybindings
C-w h/j/k/l to move. Please note
C-w h is more efficient than
C-x o. It's because
w key is more close than
x key and
h/j/k/l is easy to press.
Here is my configuration:
(global-set-key (kbd "C-c C-b C-k") 'buf-move-up) (global-set-key (kbd "C-c C-b C-j") 'buf-move-down) (global-set-key (kbd "C-c C-b C-h") 'buf-move-left) (global-set-key (kbd "C-c C-b C-l") 'buf-move-right)
I use keyfreq to record all my key pressing for more than six months.
According to the data collected by keyfreq, more than 99 percent of my moving focus between windows is done through window-numbering.el.
So it's necessary to optimize window-numbering.el further. By default, window-numbering.el uses
M-num key to select window which is already efficient. But as a geek, I have a tendency to push the efficiency to the extreme end.
Finally I use hotkey =,1=, =,2=, and =,3= to switch to the window numbering
Here is the code:
(define-key evil-normal-state-map ",1" 'select-window-1) (define-key evil-normal-state-map ",2" 'select-window-2) (define-key evil-normal-state-map ",3" 'select-window-3) (define-key evil-normal-state-map ",4" 'select-window-4)
Check my setup at github.