Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Turn On Line Numbers For Python Automatically In Emacs

I added this to my `~/.spacemacs` file to turn on relative line numbers when in Python mode:

Code

(add-hook 'python-mode-hook 
  (lambda () 
    (display-line-numbers-mode +1)
    (setq display-line-numbers 'relative)
    ))

I had to move this outside of the user `(defun dotspacemacs/user-config () ... )` config section. It doesn't work if you put it in there.

This example uses python. It works with other modes as well. I confirmed the name of the hook finding the name of the variable via `C-h v` then typing `hook` and scanning the results to find what I'm looking for.