Windows (and probably most other OSes) have a nice feature that allows one to move around and select text more efficiently. When using Ctrl (+ Shift]) + left/right arrow, one can jump or select chunks of text (delimited by spaces, dashes and others). My problem is that I usually want this behavior to recognize and stop on a more extensive list of characters (for example the underscore _).

Is this behavior built in into Windows? Can it be overridden system-wide or by application developers?

  • Good question. I've always wanted to prevent programs from stopping the cursor on certain characters, such as the dash. – Twisty Impersonator Apr 18 '17 at 14:48

We can experiment on this string (paste it into Notepad or something):


I found that !, $, %, (, -, +, {, }, [, |, \, and ? all have some effect on line breaking or character clustering. Weirdly, there seem to be multiple types of influence - they vary in whether they can break lines and whether a Control+Arrow stops before or after. (And the omission of ] is not an accident. The opening brace has special properties, but the closing one not so much.)

Each edit control in Windows has a word-breaking procedure. Such a procedure is responsible for:

  • Determining a given character's behavior with regard to word wrapping
  • Determining whether a character is a delimiter
  • Finding the beginning of the next/previous word/cluster relative to the current position

Most applications use the Windows default one, which as far as I can tell is not configurable. A given edit control or rich text control's word-breaking procedure can be set with the EM_SETWORDBREAKPROC window message. Generally this would be done by the application that owns the control, since the address of the procedure will only be guaranteed valid within that process. Programmatically, you might be able to create a thread inside a target application's process that sets a custom breaking procedure on your target controls, but there does not seem to be a less tricky way.

  • Wow, great answer. Too bad there's not a simple way to change this behavior. – Twisty Impersonator Apr 18 '17 at 17:57

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.