I'm using Terminal on Snow Leopard.
At the command line, if I've typed foo.bar.baz.bang.quuz.quux
, when i tap option-B, it moves the cursor backward word by word -- stopping at every period, because it considers a period to be a word boundary. Likewise, option-F moves forward word by word.
In irb (0.9.5, ruby 1.8.7), option-B and -F also have this behavior, but the period is no longer treated as a word boundary, which makes these keyboard shortcuts significantly less useful.
How can I change this?
EDIT: Curiouser and curiouser: On an EC2 instance which has the same irb and ruby versions, the period is treated as a word boundary.
For example, the / three / little / pigs / went / to / market. . . . Indivisibility: Say a sentence out loud, and ask someone to 'add extra words' to it. The extra item will be added between the words and not within them.
Word Boundary: \b The word boundary \b matches positions where one side is a word character (usually a letter, digit or underscore—but see below for variations across engines) and the other side is not a word character (for instance, it may be the beginning of the string or a space character).
There are three different positions that qualify as word boundaries: At string start, if the first string character is a word character \w . Between two characters in the string, where one is a word character \w and the other is not. At string end, if the last string character is a word character \w .
1 The phonological phrase boundary is the strongest of all. An l in English is dark before consonants and also before a phonological phrase boundary, that is, when the speaker pauses. This is all we have to say about this boundary here, we will not be concerned with it any further in this chapter.
I think this has more to do with the Readline module.
The word break characters can be changed. Run this in your IRB and see what characters is Readline using:
Readline.basic_word_break_characters
Readline is part of the standard ruby library: http://ruby-doc.org/stdlib/libdoc/readline/rdoc/index.html
Could this be of relevance here?
http://jorgebernal.info/2009/11/18/fixing-snow-leopard-ruby-readline/
In any case make sure option-B/F are actually bound to forward and backward-word in your inputrc files, like John pointed out.
Also word boundaries are determined by your locale (see the "locale" command), and more specifically by LC_CTYPE (character classification). I don't think that's the problem here, but you might want to check out and compare your locale settings just in case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With