Hot answers tagged

136 votes

How to switch between windows quickly?

One way is to use windmove. With its default keybindings, it allows switching to the window next to the currently active one. It's built in Emacs, so there is no need to install anything; just ...
74 votes
Accepted

How to switch between windows quickly?

I obviously prefer ace-window for this. You can switch between visible windows and frames. It's in MELPA, you can install it quickly. The only thing left to do is to bind it: (global-set-key (kbd "C-...
  • 13.6k
48 votes
Accepted

What's the difference between a buffer, a file, a window, and a frame?

Emacs predates contemporary window-based operating systems, so its terminology also predates the current terms. Unfortunately, it means that new users and experienced users sometimes have trouble ...
  • 31.4k
40 votes
Accepted

How to Change size of split screen emacs windows?

C-x- (shrink-window-if-larger-than-buffer) to shrink a window to fit its content. C-x+ (balance-windows) to make windows the same heights and widths. C-x^ (enlarge-window) to increase height by 1 ...
  • 6,111
32 votes
Accepted

Synchronized scrolling in two windows

M-x scroll-all-mode does exactly that. You can also refer to the emacs wiki on scroll-all-mode and how to make synchronized scrolling work with mouse scrolling.
  • 24.5k
29 votes

How to switch between windows quickly?

You can bind other-window to an easier-to-type key sequence. For example, I have C-. bound to other-window, and C-, bound to go to the previous window. (global-set-key (kbd "C-.") #'other-window) (...
  • 8,659
28 votes
Accepted

Switching between window layouts

The built in way to do this is with registers. For instance use C-xrwa to save the current window configuration to register a. Then you can use the built in binding C-x1 to run delete-other-windows ...
25 votes
Accepted

How to count all of the windows in a frame?

If you mean the number of windows regardless of which buffers are showing, then: (length (window-list)) will do it. Better still, you can just use the existing (count-windows) function. If you want ...
  • 31.4k
24 votes

Switching between window layouts

I use winner-mode. Here's my setup: (winner-mode) (global-set-key [f7] 'winner-undo) (global-set-key [C-f7] 'winner-redo) (global-set-key [f9] 'delete-other-windows) (global-set-key [C-f9] 'delete-...
  • 13.6k
24 votes

How to change Emacs windows from vertical split to horizontal split?

Alternatively, there's a tranpose-frame package on EmacsWiki that will allow you to transpose the whole frame, as well as do other transformations (rotate by by 180 degrees; rotate by 90 degrees ...
  • 3,288
23 votes
Accepted

Moving the mode line and minibuffer to the top

The content of the mode-line are stored in the variable mode-line-format. Emacs also supports a header line whose content is steered by the variable header-line-format. In principle you can use (...
  • 2,457
21 votes
Accepted

How can I prevent a command from using specific windows?

I second @Nsukami's suggestion to use dedicated windows. Since it is a function, not a command, using set-window-dedicated-p directly can be cumbersome. With the following command and associated key ...
  • 14.3k
19 votes
Accepted

How do I force a specific buffer to open in a new window?

It is possible to configure how a buffer opens (in the same frame/window or a different frame/window) using display-buffer-alist. Refer to the references below to learn more about this variable. ...
  • 24.5k
19 votes

How to change Emacs windows from vertical split to horizontal split?

The transpose-frame package is available on MELPA as well. Use M-x transpose-frame, or bind it to something to accomplish this.
  • 1,310
19 votes
Accepted

Quick way to close all but one window, and then revert to previous window setup?

The different sections of text you see in your Emacs are windows. You can, for example, create a new window with C-x 2. Yes, this terminology is confusing. It predates most GUI systems, so it's ...
  • 8,659
17 votes
Accepted

Switch window split orientation, fastest way

Here's a defun that would do what you are looking for: (defun toggle-window-split () (interactive) (if (= (count-windows) 2) (let* ((this-win-buffer (window-buffer)) (next-win-...
  • 1,354
17 votes

Open file in new window after searching it with helm

I'm using Spacemacs (on Windows 10 if that matters) with the default keybindings. This may differ from your configuration, but I found the following ways to open files via Helm-Find-Files: Open Helm-...
16 votes
Accepted

How to change Emacs windows from vertical split to horizontal split?

Here's a simple function that will toggle between a horizontal and vertical split. It assumes you've only got two windows, and doesn't do any resizing: (defun window-split-toggle () "Toggle ...
  • 31.4k
16 votes
Accepted

"Pop" a window into a frame

Try this instead: (defun my-turn-current-window-into-frame () (interactive) (let ((buffer (current-buffer))) (unless (one-window-p) (delete-window)) (display-buffer-pop-up-frame ...
  • 21.3k
15 votes

Hide *compilation* window

Looking quickly at the code (in library compile.el), you should be able to just kill or hide the displayed buffer by using a function on hook compilation-finish-functions. To do that, use something ...
  • 71k
14 votes

How to setup default windows at startup?

Since Emacs 24.4, you can use desktop-save-mode. It's been part of Emacs for ages, but the window layout is only saved and restored since version 24.4. Just add this line in your init file: (desktop-...
14 votes

How to switch between windows quickly?

window-numbering.el ! I assign the hotkey ",1", ",2", ",3" to switch specific window (please note I use evil-mode) besides, I display the window number at the mode line in PINK color, underlined. ...
  • 4,661
14 votes

Is there a way to change color of active window's fringe?

Since you want "To better distinguish between focused window", you can use other ways to do that instead of just changing the active window's fringe color. I combine three ways to better distinguish ...
  • 2,559
13 votes
Accepted

How to get org-agenda to prefer split-window-right

I believe this behavior is not specific to org-agenda, but rather depends on the size of the window and the variables split-width-threshold and split-height-threshold. If your window is wide enough ...
  • 19.5k
13 votes

How to switch between windows quickly?

Without using any additional add-ons, you can continue to use C-x o with an optional prefix to skip over that many windows. Eg: C-u 1 C-x o will go to the next window in the order (ie, what you would ...
  • 31.4k
13 votes
Accepted

Can I split emacs the window 4 ways (vertically and horizontally) in a 4 grid layout with different files in each?

To split the window in half with a vertical divider, use the command split-window-right. To split it in half with a horizontal divider, use the command split-window-below. For example, assume we ...
  • 949
13 votes

Neotree window not resizable

Found a solution. It works if I put this into my config: (setq neo-window-fixed-size nil) The only downside is that neotree does not remember the window width. When you switch buffers it will ...
  • 411
12 votes
Accepted

Hide *compilation* window

years ago on the #emacs IRC channel I got this bit of code I've been using forever. The value "2 sec" sets the amount of time the successful compilation window stays visible. ; from enberg on #emacs (...
  • 370
12 votes
Accepted

Splitting windows on startup

Put the following code in your .emacs file: (split-window-below) (split-window-right) Another option that you can add to your .emacs file is: (split-window-vertically) (split-window-horizontally)
  • 6,654
12 votes
Accepted

Async shell process buffer always clobbers window arrangement

Since mention that the command is running asynchronously I am assuming you mean the command async-shell-command bound to M-&. You can follow the advice in documentation of async-shell-command (you ...
  • 7,328

Only top scored, non community-wiki answers of a minimum length are eligible