I want to enable display-line-numbers-mode in all buffers except pdf buffers. Can I do that without making a list of all the major modes except pdf-view mode?


1 Answer 1


Substitute my-pdf-mode-hook for whichever major-mode that should be excluded.

(global-display-line-numbers-mode t)

(add-hook 'my-pdf-mode-hook (lambda () (display-line-numbers-mode -1)))

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.