Wednesday, February 25, 2015

Re: what does iskeyword option do?

FlashBurn wrote:
> On Wednesday, February 25, 2015 at 11:31:36 AM UTC-5, Tim Chase wrote:
>> On 2015-02-25 08:02, FlashBurn wrote:
>>> I'm trying to understand the meaning of 'iskeyword' option but I
>>> can't figure out from the help what it does. Any help in finding
>>> out of the meaning of this option is greatly appreciated.
>> 'isk' contains a list of characters (or character-ranges) for those
>> characters that should be considered a "word". This comes into play
>> when using "\<", "\>", "\k" and "\K" in a regular expression; what
>> gets considered when you use "*" and "#" to search; what the "iw" and
>> "aw" text-objects select; what's considered a "w"ord motion; how
>> abbreviations are found; and plenty of other places.
>>
>> For example, by default "-" isn't part of the 'isk' setting, but if
>> you wanted "vip" to highlight/select whole CSS selectors like
>> "background-color"
>>
>> :set isk+=-
>>
>> to add the dash. Now, if you do "viw" anywhere in the attribute,
>> it will highlight/select the entire "background-color" not just
>> "background" or "color".
>>
>> It's a little tricky to add certain characters as they have special
>> meaning. The easiest way I've found is to make a range of length one
>> for "@":
>>
>> :set isk+=@-@ " add an at-sign, good for email addresses
>> " and Python decorators
>>
>> -tim
> I was trying to understand if it has a meaning in the highlight context. I'm going through an online book, Learn Vimscript the Hard Way and in the following chapter, http://learnvimscriptthehardway.stevelosh.com/chapters/46.html, it talks about the # symbol not being in iskeyword in the context of comments and highlighting and I can't figure out why this matters. I think I'm getting the meaning of this option, i.e. it defines what a word is, but why it matters in highlighting, that is not clear to me.
>
Syntax highlighting is based upon regular expressions (see :he regexp).
A commonly used thing to pick up on are: words. Most variables,
function names, and commands, for example, fit into the description of
"word". Hence, the scripts that specify syntax highlighting often use
the \k atom (see :help /character-classes); and the \k atom depends upon
the iskeyword setting. For example, syntax/latex.vim (by default)
removes the underscore from the iskeyword option because latex will
(usually) flag usage of it as an error.

Regards,
Chip Campbell

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: