Marking a Word

Today I learned something new. Or, rather, I got hit in the head with a cluebat. Peter Hwang asked how he could mark the word at point. Manuel Uberti answered that he usually uses Ctrl+Meta+SPC, which I always think of as marking the s-expression at point. Of course, that’s where the cluebat comes in because, duh, an atom is an s-expression too.

On most keyboards, it’s easier to type Ctrl+Meta+SPC that it is to type Meta+@. At least it is for me. The nice thing is you can mark subsequent words by repeating the Ctrl+Meta+SPC.

On the other hand, both methods mark from point to the end of the word so if point is in the middle of the word, you may not get what you want. You can mark the word that the point is in with er/expand-region, Magnar Sveen’s excellent semantic marking utility. The problem with er/expand-region is that it’s usually hard to mark subsequent words because it will look for the smallest enclosing semantic unit, which is probably not the next word.

So my (new) strategy is to use er/expand-region to mark the word containing the point and then Ctrl+Meta+SPC to mark subsequent words if I need to. That means I have to switch from Ctrl+=, my binding for er/expand-region, to Ctrl+Meta+SPC, but that doesn’t seem as awkward as the other methods I’ve tried.

This entry was posted in General and tagged . Bookmark the permalink.
  • twonky

    I usually mark a word by pressing Ctrl+SPC Ctrl+Right. I will adapt Ctrl+Meta+SPC it's the same result, but simpler/faster. For the situation when point is in the middle of the word, I would just do Ctrl+Left first...

  • Yang Zhao (赵扬)

    I use the excellent easy-kill package. With that, to mark the work I'm in it's M-w w. Consecutive `w` will mark next words.

    I find easy-kill working better for me than expand-region as I can be more precise (instead of just expand and shrink). I even hacked a few extra functions like "kill inside parentheses" and "remove / add wrapping parentheses".

    • jcs

      One of the replies to the original Stack Exchange question mentioned easy-kill. I'll have to take a look at it.

  • NoonianAtall

    I once saw someone suggest M-2 for expand-region, and I like it a lot, because M-w is right below it, so it's very quick to mark a region and copy it with M-2 M-2 ... M-w.