enter image description here

In the demo, there are 6 spaces between main.c (buffer name) and [parse-early_param (from which-func), 4 spaces between which-func and 53%, and 2 or 3 spaces elsewhere. How can I set the space between them just 1 (or maybe 2) in order to save space in the mode line?

  • I can't write up a full answer right now, but for saving space in the mode-line you should have a look at smart-mode-line.
    – Malabarba
    Dec 1, 2014 at 23:44
  • I do know Smart-mode-line, but it's too much for me and I got my own configuration of mode line.
    – CodyChan
    Dec 1, 2014 at 23:52

2 Answers 2


See the Elisp manual, node %-Constructs. In particular, this part:

In any construct except %%, you can add a decimal integer after the % to specify a minimum field width. If the width is less, the field is padded to that width. Purely numeric constructs (c, i, I, and l) are padded by inserting spaces to the left, and others are padded by inserting spaces to the right.

For the format of the mode line as a whole, see variable mode-line-format, which is covered in the manual at node Mode Line Format.

Generally, you do not modify mode-line-format directly, but you modify one or more of the variables that it uses as constituents. These are covered in node Mode Line Variables.

You ask, in particular, about the space between what comes from variable mode-line-buffer-identification and what comes from variable mode-line-modes. This is controlled by the right padding for the first of these variables.

For example, if mode-line-buffer-identification is ("%12b") then if you change it to ("%1b") the right padding will be reduced from 12 spaces to 1 space.


To set the space between elements of your modeline, you just have to "type" the space key. For example, in this modeline configuration, I use " -- " or " " to separate elements of my modeline.

This is one part of the setup, just to show you:

 ;; line and column
" -- ";;"[" ;; '%02' to set to 2 chars at least; prevents flickering
(propertize "%02l" 'face 'font-lock-type-face) ","
(propertize "%02c" 'face 'font-lock-type-face)
;;"] "
;; relative position, size of file
" -- "
(propertize "%p" 'face 'font-lock-constant-face) ;; % above top
" "
(propertize "%I" 'face 'font-lock-constant-face) ;; size
;;"] "
" "
  • 1
    You did set all the elements you want in mode line, but if you don't set it, it will not be shown in mode line(such as time value), how can I just change the specific element, such as I just want to change the buffer name's propertize , not the whole mode line?
    – CodyChan
    Dec 2, 2014 at 0:59
  • You should first check the content of your current mode-line-format variable: M-x describe-variable then mode-line-format. In the buffer showing you the describe variable, there is a button for customization.
    – Nsukami _
    Dec 2, 2014 at 1:11
  • As the manual suggests. do not customize mode-line-format; just customize one or more of its component variables. In this case, variable mode-line-buffer-identification is probably all that is needed.
    – Drew
    Dec 2, 2014 at 6:08

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.