Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I double click 'abcd_efg', emacs selects the part 'abcd' or 'efg' depending on what I click. How can I select the whole string 'abcd_efg' instead? Thank you.

share|improve this question

migrated from Feb 20 '13 at 21:47

This question came from our site for professional and enthusiast programmers.

Either do what @jcubic suggested or just double-click the _ char in the symbol name. That's what I do.

That way, you can do either: select a word (e.g., a piece of a symbol name) or select an entire symbol name. Yes, you have to pay a little more attention to where you click, but you get more flexibility.

share|improve this answer

You can call (modify-syntax-entry ?_ "w") that will define underscore as part of the word.

share|improve this answer

I use this one, which I slightly modified from a google post (!topic/

(defun get-word-boundary ()
 "Return the boundary of the current word.
 The return value is of the form: (cons pos1 pos2).
  (let (p1 p2)
    (skip-chars-backward "-A-Za-z0-9_.") ;; here you can choose which symbols to use
    (setq p1 (point))
    (skip-chars-forward "-A-Za-z0-9_.") ;; put the same here
    (setq p2 (point)))
   (cons p1 p2)
(defun select-word ()
"Mark the url under cursor."
;  (require 'thingatpt)
(let (bds)
  (setq bds (get-word-boundary))

  (set-mark (car bds))
  (goto-char (cdr bds))
(global-set-key [double-mouse-1] 'select-word)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.