When I split window in emacs several times (under terminal) the whole screen is divided into several parts with hierarchical arrangement. In vim it is easy to开发者_开发技巧 switch between windows intuitively with Control-w + (h,j,k,l), but in Emacs I can only use Control-x + o to switch to "the other window", which probably would require several iterations to finally get to the window I intend. I wonder if there is a better way similar to that in Vim to easily navigate between windows?
Have you tried WindMove? It comes bundled with Emacs 21+. You move around with Shift-up, Shift-down, Shift-left, and Shift-right, though you can change the modifier. From the docs:
;; Installation:
;;
;; Put the following line in your `.emacs' file:
;;
;; (windmove-default-keybindings) ; shifted arrow keys
;;
;; or
;;
;; (windmove-default-keybindings 'hyper) ; etc.
;;
;; to use another modifier key.
;;
;;
;; If you wish to enable wrap-around, also add a line like:
;;
;; (setq windmove-wrap-around t)
I find the default binding for other-window
to be really tedious, too. I've defined the following in my .emacs
:
(global-set-key [(control ?,)] (lambda () (interactive) (other-window -1)))
(global-set-key [(control ?.)] (lambda () (interactive) (other-window 1)))
Just find some easy-to-reach keybindings (I use a Dvorak layout, so C-, and C-. may not be as easy for you to reach), preferably right next to each other, to bind to those lambdas.
Also, I found the Emacs wiki a few months ago. Nifty Tricks has a nice list of ways to make Emacs easier to use!
In Icicles, by default C-x o is bound to the multi-command icicle-other-window-or-frame
, which works this way:
With no prefix arg or a non-zero numeric prefix arg: If the selected frame has multiple windows, then this is
other-window
. Otherwise, it isother-frame
.With a zero prefix arg (e.g. C-0): If the selected frame has multiple windows, then this is
icicle-select-window
with windows in the frame as candidates. Otherwise (single-window frame), this isicicle-select-frame
.With plain C-u: If the selected frame has multiple windows, then this is
icicle-select-window
with windows from all visible frames as candidates. Otherwise, this isicicle-select-frame
.
Well then, what are icicle-select-window
and icicle-select-frame
?
They are multi-commands that let you choose a window or frame to select by name. (You can bind them separately, if you want -- they each change their behavior based on their own prefix args.)
Window and frame names are taken from their displayed buffers, with [N]
(N
=1,2,...) appended if needed for a unique name if the same buffer is displayed in more than one window/frame.
Being multi-commands, you can choose by completing and/or cycling. Completion can be prefix, substring, regexp, or fuzzy.
http://www.emacswiki.org/emacs/Icicles_-_Multi-Commands
See switch-window
. It will number windows to let you switch directly to the one you want.
That was also my first experience with emacs. But, using windmove, I can suite it, they way I want it. I use this as the modifier for windmove :
(windmove-default-keybindings 'meta)
I use ALT for the navigation of windmove
精彩评论