Currently have a GUI version of GNU Emacs v.26.3 (on MacOS Catalina, also have a similar version on Ubuntu 16.04), and because I'm just getting started with the editor, I have this question: how do I configure it to start up in the middle of the screen, and not in top-left corner?


3 Answers 3


Customize default-frame-list to have values for frame parameters top and left that put it in the middle of your screen. (Use M-x customize-option default-frame-alist.)

If that doesn't do the job then try the same thing with initial-frame-alist instead (or in addition).

  • thank you, I'll try that!
    – wintermute
    Mar 18, 2020 at 1:45

Here is a function that can be called to center the current frame.

(defun frame-center ()
  "Center the current frame."
  (let* ((dw (display-pixel-width))
         (dh (display-pixel-height))
         (f  (selected-frame))
         (fw (frame-pixel-width f))
         (fh (frame-pixel-height f))
         (x  (- (/ dw 2) (/ fw 2)))
         (y  (- (/ dh 2) (/ fh 2))))
    (message (format "dw %d dh %d fw %d fh %d x %d y %d" dw dh fw fh x y))
    (set-frame-position f x y)))

It can be called interactively via M-x frame-center or it can be placed in your config file to center your emacs on startup.

  • 1
    I followed this very readable example and it (, like, totally :-) worked! Note: I had to make sure to double check my own typing and, in my case, I wanted to move one of two frames to another monitor. But highly similar use case.
    – davernator
    Apr 13 at 18:37
  • @davernator I forgot that I wrote this function. I'm glad it worked for you, though.
    – g-gundam
    Apr 14 at 23:21

I tried both methods and still not centring on the screen.

  • 1
    I tried posting as a question to but was unable as said to fix the error I tried changing the tag name but was unsuccessful. I want to ask the same question as the answer given did not work.
    – James Cobb
    Oct 24, 2022 at 17:49
  • Check out the frame-center function I wrote as an answer to this question.
    – g-gundam
    Oct 24, 2022 at 21:09
  • 1
    Thank-you G Gundam, That's what I needed and works. Shame it was so difficult to find an answer and not much on the web about it. Many thanks James
    – James Cobb
    Oct 26, 2022 at 19:51
  • 1
    Hi again, The centring works when called with M-x frame-center but not on emacs loading, I have to call it. I put your code in my emacs config and tried adding (frame-center t) but that did not work. Any thoughts, much appreciated. James
    – James Cobb
    Oct 26, 2022 at 20:38
  • 1
    I checked through my config and other settings for the size and placing of default window, I took them out and now my window open just off center, then when I run frame-center it corrects to the center. This is good enough for me, for now , many thanks.
    – James Cobb
    Oct 26, 2022 at 22:14

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.