Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make insert/normal use similar linum schemes

This prevents the buffer from jumping.
  • Loading branch information...
commit 8d776b9d961cfb882187e67353a026677d669208 1 parent 70a3284
Bradley Wright authored
Showing with 12 additions and 5 deletions.
  1. +12 −5 packages/init-linum-relative.el
17 packages/init-linum-relative.el
View
@@ -3,16 +3,23 @@
(use-package linum-relative
:init
(progn
+ (defun my-linum-formatter (line-number)
+ (propertize (format linum-relative-format line-number) 'face 'linum))
+ (setq linum-format 'my-linum-formatter)
;; turn on linum-mode, and make it relative
- (add-hook 'evil-normal-state-entry-hook (lambda ()
- (setq linum-format 'linum-relative)
- (linum-mode 1)))
+ ;; emacs mode never shows linum
+ (add-hook 'evil-emacs-state-entry-hook (lambda ()
+ (linum-mode -1)))
+ (add-hook 'evil-emacs-state-exit-hook (lambda ()
+ (linum-mode 1)))
+ ;; in normal mode, show relative numbering
+ (add-hook 'evil-normal-state-entry-hook (lambda ()
+ (setq linum-format 'linum-relative)))
;; turn off linum-mode, and make it normal again
(add-hook 'evil-normal-state-exit-hook (lambda ()
- (setq linum-format 'dynamic)
- (linum-mode -1)))
+ (setq linum-format 'my-linum-formatter)))
;; copy linum face so it doesn't look weird
(custom-set-faces
Please sign in to comment.
Something went wrong with that request. Please try again.