Search code examples
emacswindowsplitemacs23

How can I switch focus after buffer split in emacs?


I would like that after splitting the window (C-x 3 or C-x 2) to be able to automatically get to cursor in the new opened buffer (the other than the current). How can I achieve this behavior ?


Solution

  • !!!DO NOT USE THIS ANSWER!!! -- as pointed out in the comments, advising split-window can lead to undesired side-effects.

    I recommend Bozhidar Batsov's answer instead.


    Put the following in your .emacs file:

    (defadvice split-window (after move-point-to-new-window activate)
      "Moves the point to the newly created window after splitting."
      (other-window 1))