Simon
Simon

Reputation: 10150

Spacemacs hybrid line numbers

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)

Upvotes: 18

Views: 13456

Answers (2)

Jono Job
Jono Job

Reputation: 3028

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.

Upvotes: 1

StreakyCobra
StreakyCobra

Reputation: 2001

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 :-)

Upvotes: 33

Related Questions