About the iskeyword settings for PHP

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

About the iskeyword settings for PHP

sliderw

If I am at a member declaration and want to look for all places where
the member is used, * in normal mode does not work as expected. For
example:

1 class C {
2   public $foo = true;  // member declaration
3   public function bar() {
4     $this->foo = false;
5   }
6 }

If my cursor is on $foo on line 2 and I want to look for all the foo's
in the file, I hit * in normal mode. This searches for \<\$foo\> but
not for \<foo\>, so it won't find the foo on line 4.

Given my intention, I don't want * to include the $ sign in the
search. I've found that if I remove the following line from ftplugin/
php.vim:

setlocal iskeyword+=$

then it will work as expected, namely search for \<foo\>.

My questions are: Is this the right fix? Will it break something else?
Why is the $ sign added to iskeyword in ftplugin/php.vim?


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: About the iskeyword settings for PHP

Tony Mechelynck

sliderw wrote:

> If I am at a member declaration and want to look for all places where
> the member is used, * in normal mode does not work as expected. For
> example:
>
> 1 class C {
> 2   public $foo = true;  // member declaration
> 3   public function bar() {
> 4     $this->foo = false;
> 5   }
> 6 }
>
> If my cursor is on $foo on line 2 and I want to look for all the foo's
> in the file, I hit * in normal mode. This searches for \<\$foo\> but
> not for \<foo\>, so it won't find the foo on line 4.
>
> Given my intention, I don't want * to include the $ sign in the
> search. I've found that if I remove the following line from ftplugin/
> php.vim:
>
> setlocal iskeyword+=$
>
> then it will work as expected, namely search for \<foo\>.
>
> My questions are: Is this the right fix? Will it break something else?
> Why is the $ sign added to iskeyword in ftplugin/php.vim?

No, it isn't the right fix: you should *never* alter *anything* in the
$VIMRUNTIME directory tree because any update may remove your changes without
warning (and sooner or later one of them will).

The right way to fix it is to override it by a "user" ft-plugin in an
"after-directory" (q.v.) as follows:

The file should be named (on Unix) ~/.vim/after/ftplugin/php.vim or (on
Windows, but in Vim notation) ~/vimfiles/after/ftplugin/php.vim -- create the
file and its directories if they don't exist yet.

Into that file, write the single line:

        setlocal iskeyword-=$


Since I don't know PHP, I can't tell whether this will break something else;
at least it will fix the problem you described.


Best regards,
Tony.
--
Behold the warranty ... the bold print giveth and the fine print taketh
away.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: About the iskeyword settings for PHP

Charles E Campbell Jr
In reply to this post by sliderw

Quoting sliderw <[hidden email]>:

>
> If I am at a member declaration and want to look for all places where
> the member is used, * in normal mode does not work as expected. For
> example:
>
> 1 class C {
> 2   public $foo = true;  // member declaration
> 3   public function bar() {
> 4     $this->foo = false;
> 5   }
> 6 }
>
> If my cursor is on $foo on line 2 and I want to look for all the foo's
> in the file, I hit * in normal mode. This searches for \<\$foo\> but
> not for \<foo\>, so it won't find the foo on line 4.
>
> Given my intention, I don't want * to include the $ sign in the
> search. I've found that if I remove the following line from ftplugin/
> php.vim:
>
> setlocal iskeyword+=$
>
> then it will work as expected, namely search for \<foo\>.
>
> My questions are: Is this the right fix? Will it break something else?
> Why is the $ sign added to iskeyword in ftplugin/php.vim?

As I don't use php, I can't answer your last question.  However, removing
or modifying anything in the system directories is a Bad Idea.  The next time
you update vim, your emendations are no longer active.

Instead, place your changes in your personal ~/.vim directories.  In this case,
you want to remove something that a standard plugin somewhere is doing; so,
I suggest putting a line in:

  ~/.vim/after/ftplugin/php.vim

such as

  setlocal iskeyword-=$

Regards,
Chip Campbell





--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: About the iskeyword settings for PHP

Antony Scriven-3
In reply to this post by sliderw

On 25/07/07, sliderw <[hidden email]> wrote:

 > [...]
 >
 > Why is the $ sign added to iskeyword in ftplugin/php.vim?

Because it's a keyword character in php! Otherwise stuff
like `daw' or more importantly tag-related commands might
not do what you expect. --Antony

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: About the iskeyword settings for PHP

Jack Donohue

> > Why is the $ sign added to iskeyword in ftplugin/php.vim?
>
> Because it's a keyword character in php! Otherwise stuff
> like `daw' or more importantly tag-related commands might
> not do what you expect. --Antony

But it has exactly the same use as in perl, and the perl scripts don't
include the $ in the word search (* or #).


Jack


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: About the iskeyword settings for PHP

Antony Scriven-3

On 25/07/07, Jack Donohue <[hidden email]> wrote:

 > > > Why is the $ sign added to iskeyword in ftplugin/php.vim?
 > >
 > > Because it's a keyword character in php! Otherwise stuff
 > > like `daw' or more importantly tag-related commands might
 > > not do what you expect. --Antony
 >
 > But it has exactly the same use as in perl, and the perl
 > scripts don't include the $ in the word search (* or #).

Okay, scratch that. A quick test here reveals that I need
isk-=$ for ^] to work properly to jump to tags; and yet
I use it at work without problems. Probably I've done
something to my setup ... :-) However we do seem to need
isk+=$ for [i etc. to work properly, maybe that was the
maintainer's motivation. --Antony

P.S. The maintainer seems to be unreachable at the address
noted in php.vim. Dan Sharp, and syntax maintainer Peter
Hodge, do either of you read this list? I sent you both
patches in May.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---