Browse Source

Use next-logical-line when multiple-cursors is active

This along with macoy-end-of-line makes multiple-cursors editing pretty robust against visual
wrapping mucking with the edit
master
macoymadson@gmail.com 3 years ago
parent
commit
fe870a3154
  1. 38
      Emacs/keybinds.el
  2. 8
      Emacs/visual-early.el

38
Emacs/keybinds.el

@ -100,17 +100,37 @@
;; Go to first character of line, not beginning of line. Was move-beginning-of-line
(global-set-key (kbd "<home>") 'back-to-indentation)
;; Go to end of line if multiple-cursors is active. This is important because you
;; might be editing lines which wrap without your knowledge
(defun macoy-end-of-line ()
(interactive)
(if (bound-and-true-p multiple-cursors-mode)
(call-interactively 'end-of-line)
(call-interactively 'end-of-visual-line)
(when (require 'multiple-cursors)
;; Go to end of line if multiple-cursors is active. This is important because you
;; might be editing lines which wrap without your knowledge
(defun macoy-end-of-line ()
(interactive)
(if (bound-and-true-p multiple-cursors-mode)
(call-interactively 'end-of-line)
(call-interactively 'end-of-visual-line)
)
)
)
(global-set-key (kbd "<end>") 'macoy-end-of-line)
(global-set-key (kbd "<end>") 'macoy-end-of-line)
(defun macoy-next-line (&optional arg)
"Go to next logical line if multiple-cursors is active. This is important because you might be
editing lines which wrap without your knowledge"
(interactive)
(if (bound-and-true-p multiple-cursors-mode)
(next-logical-line arg)
(next-line arg)
)
)
(defun macoy-prev-line ()
(interactive)
(macoy-next-line -1)
)
(global-set-key (kbd "<down>") 'macoy-next-line)
(global-set-key (kbd "<up>") 'macoy-prev-line)
)
;; Toggle comment lines (same keybind as Sublime). This also works for regions
(global-set-key (kbd "C-/") 'comment-line)

8
Emacs/visual-early.el

@ -44,22 +44,22 @@
;; (smooth-scrolling-mode 1)
;; This is a hack to work around smooth scrolling only being problematic on next-line and prev-line.
;; It's not really worth the effort, but I'm keeping this here in case I change my mind later
;; (defun macoy-prev-line ()
;; (defun macoy-prev-line-noscroll ()
;; (interactive)
;; (smooth-scrolling-mode 0)
;; (forward-line -1)
;; (smooth-scrolling-mode 1)
;; )
;; (defun macoy-next-line ()
;; (defun macoy-next-line-noscroll ()
;; (interactive)
;; (smooth-scrolling-mode 0)
;; (forward-line)
;; (smooth-scrolling-mode 1)
;; )
;; (global-set-key (kbd "<up>") 'macoy-prev-line)
;; (global-set-key (kbd "<down>") 'macoy-next-line)
;; (global-set-key (kbd "<up>") 'macoy-prev-line-noscroll)
;; (global-set-key (kbd "<down>") 'macoy-next-line-noscroll)
;; Make scrolling less jumpy: this makes it so emacs never centers the cursor if you go scroll off
;; screen, instead, it will scroll by one line. This isn't ideal (smooth-scrolling is ideal), but

Loading…
Cancel
Save