4

I'm looking at a file that has this in the .vimrc file:

set iskeyword+=@-@

I assumed it would let me delete a word with a hypen surrounded by two letters such as this-word with a dw command but it doesn't seem to work.

2
  • OK, it looks like it adds @ as a character so it will be considered part of the word. But I don't understand the syntax here. Why the @ followed by a hyphen and another @ sign?
    – StevieD
    Feb 11 '17 at 23:57
  • Actually, I'm wrong. Result of set iskeyword is iskeyword=@,48-57,_,192-255,$,%,@-@,: with a literal @-@ in there.
    – StevieD
    Feb 12 '17 at 0:05
7

From :h 'isk:

See 'isfname' for a description of the format of this option.

Then from :h 'isf:

If the character is '@', all characters where isalpha() returns TRUE
are included.  Normally these are the characters a to z and A to Z,
plus accented characters.  To include '@' itself use "@-@".

So, as you said in your comment, it seems that @-@ stands for the @ character itself.

As to why this syntax is used, I suppose the reason is because a single @ is already used to denote all characters where isalpha() returns TRUE, which usually are the characters a to z and A to Z, plus accented characters. So, @ couldn't be used to denote itself.

As a workaround, maybe the syntax used to express a range of characters was chosen instead.
The same syntax which is used, for example, to stand for all the alphabetical characters written in lowercase: a-z.

Maybe @-@ could be interpreted as the range of characters between the @ character, and the @ character, that is only the @ character and nothing else.

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.