Skip to content

Instantly share code, notes, and snippets.

@ivan-krukov
Last active March 6, 2023 12:11
Show Gist options
  • Save ivan-krukov/63a586f2121519ca51b201c634402a84 to your computer and use it in GitHub Desktop.
Save ivan-krukov/63a586f2121519ca51b201c634402a84 to your computer and use it in GitHub Desktop.
Personal setup for modal navigation with view mode
;; add view mode keybindings
(use-package view
:config (setq view-read-only t) ;; C-x C-q can also toggle view-mode
:straight nil
:bind (("<f13>" . view-mode) ;; remap R-Shift to F 13
:map view-mode-map
("n" . forward-line)
("p" . previous-line)))
;; make sure the cursor is changed visually
(setq-default cursor-type 'bar)
(add-hook 'view-mode-hook (defun view-mode-change-cursor-type-hook ()
(setq cursor-type (if view-mode 'box 'bar))))
;; NB: using a defun in the hook, so debugging is easier
@abhishekchandratre
Copy link

We could map 'n' to next-line, instead of forward-line.
next-line, previous-line obey column width, forward-line snaps to column 0 and proceeds.

Thank you for the gist.
//Abhishek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment