How can I configure spacemacs to always have linum-mode active in C/C++ buffers (cc-mode)?

  • 3
    There goes the StackOverflow mantra: "what have you tried?". When asking questions of this kind it's best to tell what you have already tried to prevent obvious answers (in this case the obvious answer is to add (linum-mode) to the c-mode-hook.)
    – wvxvw
    Mar 17 '15 at 9:49
  • 1
    not really, the question is spacemacs specific.
    – Roskoto
    Mar 17 '15 at 12:48

If it is specific to spacemacs then you can add this line in your dotspacemacs/config:

(add-to-hooks 'linum-mode '(c-mode-hook c++-mode-hook))
  • This might be obvious but I'm new to spacemacs and I have to ask. Where exactly is this dotspacemacs/config file?
    – Roskoto
    Mar 17 '15 at 8:50
  • 1
    Never mind I found it. in .spacemacs file: (defun dotspacemacs/config () (add-to-hooks 'linum-mode '(c-mode-hook c++-mode-hook)) )
    – Roskoto
    Mar 17 '15 at 8:57
  • Is this still valid ? I get Error in dotspacemacs/user-config: Symbol's function definition is void: add-to-hooks
    – nha
    Mar 10 '16 at 9:26
  • 1
    @nha: The function is now called spacemacs/add-to-hooks.
    – jazzpi
    May 10 '17 at 10:26

You could put this in dotspacemacs/config:

(with-eval-after-load 'linum

The relative number line will be by default.

  • For me the (global-linum-mode) was not needed, just the next two lines.
    – Zitrax
    May 2 '18 at 21:22

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.