Hot answers tagged

21 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.
salotz's user avatar
  • 1,370
20 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 ...
zck's user avatar
  • 9,004
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-...
Jason Down's user avatar
15 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 ...
JCC's user avatar
  • 989
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 ...
CodyChan's user avatar
  • 2,599
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 ...
Rotareti's user avatar
  • 426
11 votes

How can I tell Emacs to always open help buffers in the current window?

If you don't like how help-window-select works you can simply use this code: (add-to-list 'display-buffer-alist '("*Help*" display-buffer-same-window)) You can change "*Help*" with a ...
Jules's user avatar
  • 1,275
11 votes
Accepted

Open new window and switch to it

The following code written by Dawid Eckert and published in his github emacs.config moves the cursor to the newly created buffer: (defun split-and-follow-horizontally () (interactive) (split-...
manandearth's user avatar
  • 2,088
10 votes
Accepted

How to tell if more than one window is open?

You can use the built-in function one-window-p. From C-h S one-window-p: -- Function: one-window-p &optional no-mini all-frames This function returns ‘t’ if the selected window is the only ...
xuchunyang's user avatar
  • 14.3k
10 votes
Accepted

`switch-to-buffer` vs. `pop-to-buffer-same-window`

The difference is that pop-to-buffer-same-window doesn't insist as much about using the same window. Historically, switch-to-buffer has been used for 2 purposes: change which buffer is shown in the ...
Stefan's user avatar
  • 26.2k
10 votes

Open new window and switch to it

C-x4b runs switch-to-buffer-other-window which switches to the specified buffer (but creates it only there's only one buffer displayed). For more sophisticated behaviour, you'd have to implement the ...
choroba's user avatar
  • 1,925
9 votes

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

Using winner-mode is handy, but if you really just want to flip back and forth between one window and a multi-window configuration, here's something I've used before: (defvar window-split-saved-...
glucas's user avatar
  • 20.2k
9 votes
Accepted

org-babel result to a separate buffer

I've looked through documentation but it seems like there's no such option. Surprising that org does not offer :output buffer option. Maybe this is in the works for future org versions. ... place ...
Emacs User's user avatar
  • 5,553
9 votes

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

Use the split-window-xxx commands, as described in another answer. If you always want a grid of 4 windows, here's a command you could use: (defun split-4-ways () (interactive) (delete-other-...
glucas's user avatar
  • 20.2k
9 votes
Accepted

Remapping C-x C-b to Open List of Buffers in Same Window

I highly recommend using ibuffer in place of the default list-buffers command. This will provide not only the behaviour you're after, but also a tremendous amount of additional functionality in terms ...
phils's user avatar
  • 48.9k
8 votes
Accepted

How to determine the line number of the first visible line of a window?

If the user is not getting the line number multiple times each command loop for various positions, then using line-number-at-pos is sufficient -- it will get a line number even if point is not visible:...
lawlist's user avatar
  • 18.8k
8 votes

desktop-save-mode fails to save window layout

In order for desktop-read (the function used to restore your desktop from a file) to restore the frameset that was saved in the desktop, it must call desktop-restoring-frameset-p (i.e., "should I ...
cyberbisson's user avatar
8 votes
Accepted

save-excursion doesn't restore the currently visible buffer?

The current buffer need not be visible in a window. You're looking for save-window-excursion (or quite possibly a combination of the two). n.b. C-uC-ha ^save- will point out all of the following: ...
phils's user avatar
  • 48.9k
8 votes

Open helm search result in a new window?

C-z will bring up a new buffer with actions available to helm, and I see the following: [f1] Open file [f2] Open file other window [f3] Save results in buffer [f4] Edit search results So you want C-...
Mitchell Tracy's user avatar
8 votes
Accepted

Prefer vertical splits over horizontal ones

In my experience this is a harder problem that one might think, because one's intuitive idea of what is sensible is not always easy to put in precise terms. I'll just describe what I've ended up with, ...
Paul Stanley's user avatar
8 votes
Accepted

Open org link in the same window

The behaviour for opening files is set in org-link-frame-setup. By default, the behaviour for opening files is file-find-other-window. The following two alternative commands will change that so that ...
Peter Prevos's user avatar
7 votes

How can I adjust the fixed-width of a Neotree buffer?

You can disable neo-window-fixed-size and restart Neotree.
Blaz's user avatar
  • 199
7 votes
Accepted

One window per project

You can use perspective to manage projects. From its README: perspective.el provides multiple workspaces (or "perspectives") for each Emacs frame. This makes it easy to work on many ...
cutejumper's user avatar
7 votes

Open org link in the same window

This works for me: (setq org-link-frame-setup '((vm . vm-visit-folder-other-frame) (vm-imap . vm-visit-imap-folder-other-frame) (gnus . org-gnus-no-new-news) (file . find-file) ...
Edman's user avatar
  • 1,167
6 votes

Single mode line for all windows

I've finally achieved this by hacking emacs. You can get the source code from https://github.com/amosbird/emacs/tree/onemodeline . Basically it uses mini-window's header line to render current ...
Amos's user avatar
  • 456
6 votes
Accepted

Open file in a specific window

Allowing user to custom action is a great feature of helm, for example, to use ace-window to select a window for buffer to switch, all you need to do is implement it as an action: (defun helm-buffer-...
xuchunyang's user avatar
  • 14.3k
6 votes
Accepted

Auto adjust window width based on number of windows?

You can define your own command for this. This allows you to use it when desired, but not change the default behavior of the original commands, keeping them useful individually if desired: (defun ...
InHarmsWay's user avatar
  • 1,309
6 votes

How can I pin the *compilation* buffer to never leave a single frame/window

Normally, Emacs considers the selected frame the only reusable frame. In other words, normally Emacs only searches the current ("selected") frame for windows that already contain the buffer-to-display ...
bmag's user avatar
  • 1,703
6 votes
Accepted

How can I prevent gdb *input/output* buffer from aggressively popping up in frame?

As soon as emacs 25 lands, there will be a variable gdb-display-io-nopopup to fix this problem
ajp's user avatar
  • 393
6 votes

How to cycle between two windows when I have more than two open?

If you are already using ace-window, then you can use the command aw-flip-window to flip back and forth between two windows. By default this is bound to n in the ace-window aw-dispatch-alist. That ...
glucas's user avatar
  • 20.2k

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