Skip to content

Instantly share code, notes, and snippets.

@andiogenes
Created July 20, 2022 03:52
Show Gist options
  • Save andiogenes/a7c23a6b09782049d1afac11ca391172 to your computer and use it in GitHub Desktop.
Save andiogenes/a7c23a6b09782049d1afac11ca391172 to your computer and use it in GitHub Desktop.
;;; Relative line numbers
(setq display-line-numbers-type 'relative)
(global-display-line-numbers-mode)
;; Move toward logical lines when prefix arg (numeric, negative) is presented
(defun next-logical-line-if-prefix (&optional arg try-vscroll)
(interactive "^p\np")
(let ((line-move-visual (if current-prefix-arg nil line-move-visual)))
(with-no-warnings
(next-line arg try-vscroll))))
(defun previous-logical-line-if-prefix (&optional arg try-vscroll)
(interactive "^p\np")
(let ((line-move-visual (if current-prefix-arg nil line-move-visual)))
(with-no-warnings
(previous-line arg try-vscroll))))
(global-set-key (kbd "C-n") 'next-logical-line-if-prefix)
(global-set-key (kbd "C-p") 'previous-logical-line-if-prefix)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment