iskeyword setting controls this. You can add
! to it with:
:setlocal iskeyword+=? iskeyword+=!
Or, for just Ruby from your vimrc:
autocmd Filetype Ruby :setlocal iskeyword+=? iskeyword+=!
Do not use
set iskeyword=.. from your vimrc, as that will likely lead to problems with other filetypes.
iskeyword setting is used for many commands; for example:
dw would previously delete up to a
?, but now it will also delete the
gf will now also match
# is this file correct: a.rb? will try to open
a.rb? (which won't exist).
* will match the word with question-mark.
There are many more cases; the above list is not exhaustive. Some of these behaviours could be considered features, others might be considered bugs. Personally, I've learned to not frob with
iskeyword too much (in part because I like my
dw etc. to behave the same regardless of filetype), but others like to modify it extensively.
Just remember: if you run into Weird Problems™ later on then your frobbery with the
iskeyword setting could very well be the cause!