You can't get all LaTeX strings right using iskeyword
, that is because the iskeyword
works on characters and some characters may have different meanings in different contexts. A better way than b and w to test iskeyword
is viw which should visually select all characters from the cursors in both directions until it hits a character that is not in iskeyword
.
On example of where this is useful are quoted strings, for example:
"abc"
Here viw will select abc
and not the double quotes. But LaTeX can be ambiguous, how about this:
"Bj\{"o}rn"
Therefore a way to finding all possible LaTeX commands that can be inside a natural language word would require you to set iskeyword
to everything but non-printables (space, tab, and special characters).
But Vim already does that for you!
If instead of using viw, b and w, you use viW, B and W you are selecting Vim WORDs (not words). Vim makes a distinction between WORDs and words. See :h WORD
:
A WORD consists of a sequence of non-blank characters, separated with white
space. An empty line is also considered to be a WORD.
(...)
Therefore:
- Is it supposed to be so? yes, since it is the default
And moreover since the tex.vim
ftplugin did not overwrite it.
- What are better settings?
You probably should not play with iskeyword
, different file types will have different ones but most use the defaults. Messing with iskeyword
in vimrc may become a burden when you overwrite it for a filetype that needs it (you could write your own ftplugin for TeX but there is no real need here). Instead use WORDs where you need them.
- How to properly set this variable for this filetype?
See above.
P.S. I wrote my entire dissertation in LaTeX, and all in Vim. I have been before where you are now :).
@,48-57,_,192-255
is the default for vim. Perhaps you can tell us why it feels unnatural or what you are expecting vs. the behavior you're getting?