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.
You can split a window horizontally or vertically by clicking C-Mouse-2 in the mode line or the scroll bar.
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.
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.
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.
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.
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)
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With