Sunday, September 13, 2015

Re: dot in iskeyword in C and sh files

On Thursday, August 6, 2015 at 6:25:39 PM UTC+2, Charles Campbell wrote:
> Christian Brabandt wrote:
> > 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
> >
> One could always take the radical step of reading the help: :help
> ft-sh-syntax !

I've also run into this now after upgrading my system. With "." in
'iskeyword', editing shell scripts is less fun. I cannot use word
motions like w b as effectively any more, and * and # don't do what they
usually do in other file types.

I find the change frustrating, and this one-line response by the
maintainer is especially disappointing. Why weren't the users asked
before making a potentially disruptive change? I imagine most people
working with shell scripts will now need to add "g:sh_noisk = 1" to
their personal config for no good reason.

Good defaults are important. I believe it would be best to revert the
change and not add "." to 'iskeyword'.


--
David

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