Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs : Open buffer in vertical split by default

Tags:

emacs

I am very very new to emacs. I want something like this. Every time I open a new buffer, it should split current winodow vertically. How should I change .emacs file. Please provide some pointers.

like image 355
username_4567 Avatar asked Nov 23 '13 20:11

username_4567


People also ask

How do I split a window vertically in emacs?

You can split a window horizontally or vertically by clicking C-Mouse-2 in the mode line or the scroll bar.

How do I unsplit windows emacs?

Use the C-x b command or the Buffers menu. Or if you haven't opened the file, yet, use the C-x C-f command to open the new file in a new buffer. To unsplit the window, use the command C-x 1 or right-click on either title bar. The inactive panel disappears.

How do you split a buffer?

To put an existing buffer in a split window you use the sb# command (where # is the buffer number). Splits in VIM default to horizontal, to change this, prefix your command with vert which forces a vertical split of the next split command.

How do I open multiple emacs?

Much better to use the multiple buffer feature of emacs. If you are editing the first file and want to start editing the second file, simply use the hot key C-x C-f or the menu selection File->Open File to start the second file. The second file is loaded into its own buffer.


3 Answers

You know that you can do this manually with C-x 3 right? So we can use this fact to learn how to add the command to do this to .emacs.

We just need to find out what the function is. So let's do C-h k C-x 3 to find the help for C-x 3. That shows:

C-x 3 runs the command split-window-right, which is an interactive compiled Lisp function in `window.el'.

So, open .emacs (C-x C-f ~/.emacs), go to the end of the file and add:

(split-window-right)

Then save the file, restart emacs and it should work. I just tested it.

like image 168
Robin Green Avatar answered Oct 20 '22 06:10

Robin Green


I don't remember the exact route I followed to get this, but I have the following configuration to suggest to Emacs that it should split the frame vertically rather than horizontally when Emacs has the choice (eg when bringing up help).

This seems to work fine on my widescreen monitors.

(setq split-height-threshold nil)
(setq split-width-threshold 160)
like image 20
Stuart Hickinbottom Avatar answered Oct 20 '22 05:10

Stuart Hickinbottom


Add This to .emacs to split windows vertically as default opening a new buffer in other windows

(setq
   split-width-threshold 0
   split-height-threshold nil)
like image 3
Mario Giovinazzo Avatar answered Oct 20 '22 04:10

Mario Giovinazzo