dot in iskeyword in C and sh files

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

dot in iskeyword in C and sh files

Olaf Hering-3

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?

Olaf

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: dot in iskeyword in C and sh files

Christian Brabandt
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: dot in iskeyword in C and sh files

Olaf Hering-3
On Wed, Aug 05, Christian Brabandt wrote:

> ,----[ syntax/sh.vim ]-
> | " AFAICT "." should be considered part of the iskeyword.  Using iskeywords in
> `----

No reason given why a dot should be part of a word.
I consider this a regression which should be fixed.

> :let g:sh_noisk=1

Guess I'm forced to do that. Thanks.

Olaf

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: dot in iskeyword in C and sh files

Charles Campbell
In reply to this post by Christian Brabandt
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  !

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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: dot in iskeyword in C and sh files

Christian Brabandt
Hi Charles!

On Do, 06 Aug 2015, Charles Campbell wrote:

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

Good hint, right.

Best,
Christian
--
Nur ein unerkannter Poet kann warhaftig große Werke tun.
                -- Benjamin Stramke

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: dot in iskeyword in C and sh files

John Little-4
In reply to this post by Olaf Hering-3
On Thursday, August 6, 2015 at 10:54:07 PM UTC+12, olaf wrote:

> No reason given why a dot should be part of a word.

The Korn shell, ksh, has a syntax using dots; some kind of vaguely OO attributes.

$ x=bob
$ x.y=carol

A lot of ksh-isms found their way into POSIX, but not this one I think.  Does anyone still use ksh?

Regards, John Little

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: dot in iskeyword in C and sh files

Nikolay Aleksandrovich Pavlov
2015-08-07 1:11 GMT+03:00 John Little <[hidden email]>:

> On Thursday, August 6, 2015 at 10:54:07 PM UTC+12, olaf wrote:
>
>> No reason given why a dot should be part of a word.
>
> The Korn shell, ksh, has a syntax using dots; some kind of vaguely OO attributes.
>
> $ x=bob
> $ x.y=carol
>
> A lot of ksh-isms found their way into POSIX, but not this one I think.  Does anyone still use ksh?

I do not think that *any* fact deserves adding *any* character to the
&iskeyword option. The problem is not that some software thinks that
identifiers may contain certain characters. The problem is that when I
do dw with cursor on x I *expect* it to delete x *everywhere*.

It is absolutely not fun remembering that “fucking sh *syntax* (not
even filetype!) file messes up my keybindings so that `w` now moves
over a dot, fucking erlang syntax file adds dollar and at signs there,
…”. Too many information and messing with &iskeyword really makes `w`
(and other based on the word definition) movement not predictable in
any new filetype.

Do not remember where I suggested this, but I think that &iskeyword
value should be saved before sourcing syntax files and then restored
after sourcing. And :syntax should remember effective &iskeyword
value, so that a) syntax files work and b) user settings are
untouched.

---

And I use ksh, to test that some of my or another person’s scripts are
truly portable. But not as a shell.

>
> Regards, John Little
>
> --
> --
> 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 [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: dot in iskeyword in C and sh files

Justin M. Keyes
On Thu, Aug 6, 2015 at 6:21 PM, Nikolay Pavlov <[hidden email]> wrote:

> 2015-08-07 1:11 GMT+03:00 John Little <[hidden email]>:
>> On Thursday, August 6, 2015 at 10:54:07 PM UTC+12, olaf wrote:
>>
>>> No reason given why a dot should be part of a word.
>>
>> The Korn shell, ksh, has a syntax using dots; some kind of vaguely OO attributes.
>>
>> $ x=bob
>> $ x.y=carol
>>
>> A lot of ksh-isms found their way into POSIX, but not this one I think.  Does anyone still use ksh?
>
> I do not think that *any* fact deserves adding *any* character to the
> &iskeyword option. The problem is not that some software thinks that
> identifiers may contain certain characters. The problem is that when I
> do dw with cursor on x I *expect* it to delete x *everywhere*.
>
> It is absolutely not fun remembering that “fucking sh *syntax* (not
> even filetype!) file messes up my keybindings so that `w` now moves
> over a dot, fucking erlang syntax file adds dollar and at signs there,
> …”. Too many information and messing with &iskeyword really makes `w`
> (and other based on the word definition) movement not predictable in
> any new filetype.
>
> Do not remember where I suggested this, but I think that &iskeyword
> value should be saved before sourcing syntax files and then restored

https://github.com/neovim/neovim/issues/1285

Justin M. Keyes

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: dot in iskeyword in C and sh files

glts
In reply to this post by Charles Campbell
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: dot in iskeyword in C and sh files

Bram Moolenaar

David Burgin wrote:

> 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'.

I don't see a keyword in this syntax file that has a dot.  That would be
a valid reason for a syntax file to change 'iskeyword'.

Setting 'iskeyword' does not really belong in a syntax file.  It's best
left alone, but if a language really has a different kind of keyword it
should be set in the filetype plugin.

--
Hacker: Someone skilled in computer programming (good guy).
Cracker: A hacker that uses his skills to crack software (bad guy).

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.