Emacs: Select Text Between Quotes šŸ’ 

By Xah Lee. Date: . Last updated: .

Select Text between Quotes/Brackets

Select text inside quotes is one of the most frequently needed operation in programing languages code.

put this in your Emacs Init File:

(defvar xah-brackets '( "ā€œā€" "()" "[]" "{}" "<>" "ļ¼œļ¼ž" "ļ¼ˆļ¼‰" "[]" "ļ½›ļ½" "⦅⦆" "怚怛" "ā¦ƒā¦„" "‹›" "«»" "怌怍" "怈怉" "怊怋" "怐怑" "怔怕" "ā¦—ā¦˜" "怎怏" "怖怗" "怘怙" "「」" "⟦⟧" "⟨⟩" "⟪⟫" "⟮⟯" "⟬⟭" "āŒˆāŒ‰" "āŒŠāŒ‹" "ā¦‡ā¦ˆ" "ā¦‰ā¦Š" "ā›āœ" "āāž" "āØā©" "āŖā«" "ā“āµ" "ā¬ā­" "ā®āÆ" "ā°ā±" "ā²ā³" "〈〉" "⦑⦒" "⧼⧽" "ļ¹™ļ¹š" "ļ¹›ļ¹œ" "ļ¹ļ¹ž" "⁽⁾" "ā‚ā‚Ž" "ā¦‹ā¦Œ" "ā¦ā¦Ž" "ā¦ā¦" "⁅⁆" "⸢⸣" "⸤⸄" "āŸ…āŸ†" "⦓⦔" "⦕⦖" "⸦⸧" "āøØāø©" "⦅⦆")
 "A list of strings, each element is a string of 2 chars, the left bracket and a matching right bracket.
Used by `xah-select-text-in-quote' and others.")

(defun xah-select-text-in-quote ()
  "Select text between the nearest left and right delimiters.
Delimiters here includes QUOTATION MARK, GRAVE ACCENT, and anything in variable `xah-brackets'.
This command ignores nesting. For example, if text is
怌(a(b)cā–®)怍
the selected char is 怌c怍, not 怌a(b)c怍.

URL `http://xahlee.info/emacs/emacs/emacs_select_quote_text.html'
Created: 2020-11-24
Version: 2023-11-14"
  (interactive)
  (let ((xskipChars (concat "^\"`" (mapconcat #'identity xah-brackets ""))))
    (skip-chars-backward xskipChars)
    (push-mark (point) t t)
    (skip-chars-forward xskipChars)))

Emacs, Work with Brackets