blog::weyl.io

Chris Weyl's Technical Blog

Vim knows about a number of different character classes; each of which influence its behaviour (commands, syntax) in a variety of ways. Vim's defaults for the different classes are fairly sensible, but it's the job of a file-type plugin to adjust the defaults to what makes sense for a particular file.

Character classes {not in Vi}:                          */character-classes*
      magic   nomagic   matches
|/\i|   \i      \i      identifier character (see 'isident' option)
|/\I|   \I      \I      like "\i", but excluding digits
|/\k|   \k      \k      keyword character (see 'iskeyword' option)
|/\K|   \K      \K      like "\k", but excluding digits
|/\f|   \f      \f      file name character (see 'isfname' option)
|/\F|   \F      \F      like "\f", but excluding digits
|/\p|   \p      \p      printable character (see 'isprint' option)
|/\P|   \P      \P      like "\p", but excluding digits

Of these, I've only ever found myself tweaking the iskeyword option. Why? Well, different languages have different ideas of what constitutes a legal part of a keyword/token/etc.

An example is Perl, where for the last several years the perl runtime files have modified iskeyword to include :. This allows all sorts of good things to happen, not the least of which is completion working for Long::Package::Names.

In my own configuration, I find a couple different places in my vim configuration I've modified this option:

after/ftplugin/css.vim:9:setl iskeyword+=- after/ftplugin/html.vim:7:call s:tools.setplus('iskeyword', '-') after/ftplugin/ref-perldoc.vim:6:setl iskeyword+=: after/ftplugin/vim.vim:13:call s:tools.setplus('iskeyword', ':') after/syntax/perl.vim:22:" isident or iskeyword spell/vim.utf-8.add:78:iskeyword