Spacemacs hybrid line numbers
Asked Answered
C

2

18

How do I get hybrid line numbering (relative line numbers, but the current line shows the absolute line number instead of 0) in spacemacs for all files?

I tried setting relative line numbers in user-config but that doesn't seem to be working, and can't figure out how to replace the 0 in relative mode either:

(global-linum-mode)
(setq-default dotspacemacs-line-numbers 'relative)
Centreboard answered 18/1, 2016 at 17:15 Comment(1)
FYI emacs.stackexchange.com/questions/19532/… is a similar question (but using github.com/coldnew/linum-relative rather than this dotspacemacs-line-numbers feature).Posit
D
33

The dotspacemacs-line-numbers variable already exists in your .spacemacs, in the dotspacemacs/init function. If it is not the case you can update your .spacemacs to the last template with the help of SPC f e D.

Change its value to 'relative, as in:

;; If non nil line numbers are turned on in all `prog-mode' and `text-mode'
;; derivatives. If set to `relative', also turns on relative line numbers.
;; (default nil)
dotspacemacs-line-numbers 'relative

Then remove the two lines you added in your dotspacemacs/user-config. All you need is to change the variable as explained above, it will take care of applying the changes for you :-)

Domicile answered 19/1, 2016 at 8:19 Comment(0)
E
1

The Spacemacs setup may have changed since @StreakyCobra's answer, but my .spacemacs file didn't have a dotspacemacs-line-numbers variable already available.

In the Spacemacs docs, it suggests using (setq-default dotspacemacs-line-numbers 'relative) link the question has. I put this in the dotspacemacs/user-init section (not user-config) and it worked for me.

Note: The above sets the default. If you just want to show/hide lines numbers on a particular buffer, you can access it via SPC t n.

Elegist answered 11/4 at 23:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.