5

When strike C-x 3, a new window and buffer will open to the right of the current buffer.

How could set it open to the left of the current?

  • You mean you want the selected window being the one on the right? – JeanPierre Nov 19 at 6:32
  • Yes, I want my focus window on right and the new opened window to its left. @JeanPierre – Algebra Nov 19 at 6:42
  • Here is an example of how to display a buffer in any one of four directions, i.e., above, below, left, and right: stackoverflow.com/a/50867710/2112489 – lawlist Nov 19 at 6:49
8

C-x 3 is bound to the function split-window-right, that splits the current window horizontally, selecting the left window. We can define a function split-window-left that calls it then change the selected window to the one on the right, eg using other window:

other-window is an interactive compiled Lisp function in ‘window.el’.

(other-window COUNT &optional ALL-FRAMES)

Select another window in cyclic ordering of windows. COUNT specifies the number of windows to skip, starting with the selected window, before making the selection.

(defun split-window-left (&optional size)
  "Like split-window-right, with selected window on the right."
  (interactive "P")
  (split-window-right size)
  (other-window 1))

We keep the same semantics for the optionalsize argument: give the width of the left window if positive, of the right one if negative.

You can bind this to C-x 3 (overriding the binding to split-window-right) or to another key, eg C-x 9:

(global-set-key  "\C-x9" 'split-window-left)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.