help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I highlight word at point?


From: Xah
Subject: Re: How do I highlight word at point?
Date: Sat, 18 Oct 2008 22:44:14 -0700 (PDT)
User-agent: G2/1.0

Wei Weng wrote:
«how to highlight word at point»

You can do this:

(defun select-word ()
"Select a word under cursor.
“word” here is considered any alphenumeric sequence with “_” or “-”."
 (interactive)
 (let (b1 b2)
   (skip-chars-backward "-_A-Za-z0-9")
   (setq b1 (point))
   (skip-chars-forward "-_A-Za-z0-9")
   (setq b2 (point))
   (set-mark b1)
   )
 )

(transient-mark-mode t)

(global-set-key (kbd "M-8") 'select-word)

Then, Alt+8 will select the current word.

-----------------

This select-word command will be incorporated into the ergonomic
keymap design in the future. I just haven't decided Alt+8 is the best
spot, but i've been using it for a year. See
http://xahlee.org/emacs/ergonomic_emacs_keybinding.html

  Xah
∑ http://xahlee.org/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]