Wednesday, August 5, 2015

Re: dot in iskeyword in C and sh files

Hi Olaf!

On Mi, 05 Aug 2015, Olaf Hering wrote:

>
> Since some time cycling through variables in a shell file with the
> asterisk '*' key is broken for me. In the simple example like that:
>
> var="val"
> echo "$var.whatever"
>
> I was able to move cursor to "var=", hit "*" and saw all "var" strings
> highlighted. Recently that broken, only the assignment in above example
> is highlighted. If I put curly braces around the usage of "var" it gets
> highlighted as well. But if I move to "whatever" then "var.whatever" is
> highlighted. Surely thats wrong, "var.whatever" is not a word.
>
> After some poking I found that iskeyword= is likely the knob to change.
> First I did a test with a C file, like:
>
> struct var var;
> var.var = 0;
>
> Oddly enough, each "var" is highlighted right away, witout the dot. So
> it must be something special with files ending in ".sh". Even in this
> mail each "var" is highlighted, without the dot itself.
>
> Looking through the files provided by the vim.rpm I dont spot the place
> where also the dot is considered a word.
>
> Why does that happen for shell files?
> Why would that behaviour desirable?

Use

:verbose set iskeyword?

to find out, where it was last modified. I did so and it told me, it was
set by syntax/sh.vim

Looking into the corresponding syntax file, I find this:

,----[ syntax/sh.vim ]-
| " AFAICT "." should be considered part of the iskeyword. Using iskeywords in
| " syntax is dicey, so the following code permits the user to
| " g:sh_isk set to a string : specify iskeyword.
| " g:sh_noisk exists : don't change iskeyword
| " g:sh_noisk does not exist : (default) append "." to iskeyword
| if exists("g:sh_isk") && type(g:sh_isk) == 1 " user specifying iskeyword
| exe "setl isk=".g:sh_isk
| elseif !exists("g:sh_noisk") " optionally prevent appending '.' to iskeyword
| setl isk+=.
| endif
`----

So simply put into your .vimrc:

:let g:sh_noisk=1


Best,
Christian
--
Zwei Ordner auf der CeBIT beim passieren des LinuxParks:
Sie: Linux? Das ist doch dieses andere Windows.
Er überlegen lächelnd: Ja.

--
--
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:

Post a Comment