The functions I have found for splitting windows are (split-window-right) and (split-window-below). When these are evaluated the cursor ends up in the right window in the case of (split-window-right)or the upper window in the case of (split-window-below).

I want to have functions that split a window and puts the cursor in the right or lower window.

I wrote the following myself, but it unfortunately does not move the cursor as I expected. Instead it just behaves as if (split-window-right) was called by itself.

(defun olav-split-window-left ()
  • Starting from a single window and executing this function with M-x olav-split-window-left, it works for me as expected: it splits the window into two side-by-side windows and the window on the right is selected.
    – NickD
    Commented Jul 12, 2020 at 13:57
  • Interesting. It turns out that the function works on non-configured Emacs, but not on my configuration which is weird considering it is sub 100 loc that I just started writing today. Regardless Fran's solution worked for me.
    – fossegrim
    Commented Jul 12, 2020 at 14:50
  • I'm guessing this is a duplicate. We have many questions with tag window-splitting (and other window tags). I'm guessing many are similar or essentially the same. Would someone like to take a look and maybe consolidate as a community question or two?
    – Drew
    Commented Jul 12, 2020 at 17:11

1 Answer 1


Try this:

(defun olav-split-window-left ()
  (select-window (split-window-right)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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