0

In Ruby, and languages based on Ruby the style-guide recommends bool getter methods be named empty? as opposed to is_empty. Note the question mark.

Vim however, does not complete the ? by default. Is there a setting to enable this? Or a plugin?

1

The iskeyword setting controls this. You can add ? and ! to it with:

:setlocal iskeyword+=? iskeyword+=!

Or, for just Ruby from your vimrc:

augroup ruby_settings
    autocmd!
    autocmd Filetype Ruby :setlocal iskeyword+=? iskeyword+=!
augroup end

Do not use set iskeyword=.. from your vimrc, as that will likely lead to problems with other filetypes.


The 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 ?, so gf on # 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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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