Emacs: Commands to Jump to Punctuations

Buy Xah Emacs Tutorial. Master emacs benefits for life.
, , …,

2 commands that let you fly to any punctuation in language source code.

(defun xah-forward-equal-sign ()
  "Move cursor to the next occurrence of equal sign 「=」.
URL `http://ergoemacs.org/emacs/emacs_jump_to_punctuations.html'
Version 2015-06-15"
  (interactive)
  (search-forward-regexp "=+" nil t))

(defun xah-backward-equal-sign ()
  "Move cursor to previous occurrence of equal sign 「=」.
URL `http://ergoemacs.org/emacs/emacs_jump_to_punctuations.html'
Version 2015-06-15"
  (interactive)
  (when (search-backward-regexp "=+" nil t)
    (while (search-backward "=" (- (point) 1) t)
      (left-char))))
(defun xah-forward-dot-comma ()
  "Move cursor to the next occurrence of 「.」 「,」 「;」.
URL `http://ergoemacs.org/emacs/emacs_jump_to_punctuations.html'
Version 2015-03-24"
  (interactive)
  (search-forward-regexp "\\.+\\|,+\\|;+" nil t))

(defun xah-backward-dot-comma ()
  "Move cursor to the previous occurrence of 「.」 「,」 「;」
URL `http://ergoemacs.org/emacs/emacs_jump_to_punctuations.html'
Version 2015-03-24"
  (interactive)
  (search-backward-regexp "\\.+\\|,+\\|;+" nil t))

you need to give them a easy key for this idea to work, such as {【Ctrl+7】, 【Ctrl+8】}. 〔➤ Emacs: How to Define Keys〕 (you'll need a key that can be held down to repeat, such as 【F8】, 【Ctrl+8】, and for example 【Ctrl+c c】 wouldn't work. 〔➤ Emacs: Fast-repeat vs Non-fast-repeat Commands & Keys〕)

this is to be used together with Emacs: Commands to Move Cursor by Brackets, Quotes. If you don't have that, use the backward/forward brackets first, because that's more useful.

the jump to punctuation is inspired by ace-jump-mode: https://github.com/winterTTr by winterTTr. I heard about ace-jump from jcs's blog

Like it? Buy Xah Emacs Tutorial.
blog comments powered by Disqus