Vim Dev gurus:
The mailing list has been slow enough that several of us worried it
might be broken (or have unsubscribed us) so maybe this is a good time
to post a request for a new feature. I already raised this on the vim
users' list, but maybe starting a new thread will get more attention.
The motions w, b, e, and others depend on the definition of a word.
So do the text-object iw and insert-mode completion and <C-]> and
probably a lot of other things.
Currently, a word (:help word) consists of a sequence of keyword
characters (as specified by 'iskeyword'), separated by non-keyword
characters (or start of line or end of line). In other words, a word is
specified by the regular expression /\k\@<!\k\+/ .
I think this definition is too restrictive. I would like to have
an option, perhaps 'wordpat', that specifies what is considered a
keyword. The default would be '\k\@<!\k\+' .
Here are some examples where I am not satisfied with being able to
change 'iskeyword'. but being able to set 'wordpat' would make me happy.
Plain text:
Today (not every day) I want to treat words-with-hyphens as single
words, so I try
:setl isk+=-
The problem--depending on my style manual--is that em-dashes are treated
as parts of words. This is the problem that came up recently on the vim
users' list. Given a 'wordpat' option, I could solve this with
:let &l:wordpat = '\(\k\|-\)\@<!\k\+\(-\k\+\)*'
For other uses, you might want to do something similar with '_' or '\.'
instead of '-' .
(La)TeX:
Personally, I am in the habit of including optional spaces:
$$ \alpha \beta \gamma = \alpha + \beta + \gamma . $$
I do this for readability and also so that word motions are more
convenient. Many others prefer to omit the optional spaces:
$$ \alpha\beta\gamma = \alpha+\beta+\gamma . $$
I like to do
:setl isk+=\
so that "\alpha" is considered a single word, but I normally do not want
to consider "\alpha\beta\gamma" as a single word. (I almost wrote that
"no one" ever wants this, and I almost accused those who prefer to omit
the optional spaces of laziness, but then I remembered
:help design-flexible .) With my new proposal,
:setl isk-=\
:let &l:wordpat = '\\\=\k\@<!\k\+'
would work well with either style.
Java:
In this and other languages, someVariablesHaveLongCamelCaseNames
and users sometimes want their word motions to go up to the next capital
letter. Details left to the reader.
C:
In other languages, a more common style is the
long_var_name_with_underscores . Again, I leave the details to your
imagination.
--Benji Fisher