How to change the behavior of '*', when searching string under cursor?

3 views
Skip to first unread message

Peng Yu

unread,
Nov 29, 2008, 1:11:44 PM11/29/08
to vim_use
Hi,

I have perl.vim installed.

File::Path

Suppose I have the above text in a .pl file and the cursor is on
'Path'. When I press *, it will search for \<File::Path\>. I want vim
to search for \<Path\>. Can somebody let me know how to do it?

If the cursor is at the beginning of 'File' and I press 'd' and 'e',
vim would delete 'File::Path' completely. But I want it delete 'File'
only. Could somebody let me know how to do this as well?

Thanks,
Peng

Tim Chase

unread,
Nov 29, 2008, 1:50:55 PM11/29/08
to vim...@googlegroups.com

Though I'm not a Perl user, it sounds like you have ":" in your
'iskeyword' setting. This can be removed with

set iskeyword-=:

If it's getting set by the filetype detection of perl-scripts,
you may have to put that command in an "after" script to prevent
it from being overridden.

To read more, consult

:help 'iskeyword'
:help after-directory

-t

Tim Chase

unread,
Nov 29, 2008, 1:51:11 PM11/29/08
to vim...@googlegroups.com

Though I'm not a Perl user, it sounds like you have ":" in your

'iskeyword' setting. This can be removed with

set iskeyword-=:

If it's getting set by the filetype detection of perl-scripts,
you may have to put that command in an "after" script to prevent
it from being overridden.

To read more, consult

:help 'iskeyword'
:help after-directory

-tim

Mr. Shawn H. Corey

unread,
Nov 29, 2008, 2:39:23 PM11/29/08
to vim...@googlegroups.com

This is part of perl.vim for vim 6 and older. When I upgraded to
version 7, it when away. Could you upgrade your version?


--
Just my 0.00000002 million dollars worth,
Shawn

The key to success is being too stupid to realize you can fail.

Peng Yu

unread,
Nov 29, 2008, 3:53:48 PM11/29/08
to vim_use


On Nov 29, 1:39 pm, "Mr. Shawn H. Corey" <shawnhco...@magma.ca> wrote:
> On Sat, 2008-11-29 at 12:50 -0600, Tim Chase wrote:
> > > I have perl.vim installed.
>
> > > File::Path
>
> > > Suppose I have the above text in a .pl file and the cursor is on
> > > 'Path'. When I press *, it will search for \<File::Path\>. I want vim
> > > to search for \<Path\>. Can somebody let me know how to do it?
>
> > > If the cursor is at the beginning of 'File' and I press 'd' and 'e',
> > > vim would delete 'File::Path' completely. But I want it delete 'File'
> > > only. Could somebody let me know how to do this as well?
>
> > Though I'm not a Perl user, it sounds like you have ":" in your
> > 'iskeyword' setting.  This can be removed with
>
> >    set iskeyword-=:
>
> > If it's getting set by the filetype detection of perl-scripts,
> > you may have to put that command in an "after" script to prevent
> > it from being overridden.
>
> > To read more, consult
>
> >    :help 'iskeyword'
> >    :help after-directory
>
> This is part of perl.vim for vim 6 and older.  When I upgraded to
> version 7, it when away.  Could you upgrade your version?

The vim in my system is of version 7.0. I think that it is actually
because of perl-support that I just installed recently instead of
perl.vim as I mentioned in the original post.

http://www.vim.org/scripts/script.php?script_id=556

Is it considered a bug of perl-support?

Thanks,
Peng

Mr. Shawn H. Corey

unread,
Nov 29, 2008, 5:48:12 PM11/29/08
to vim...@googlegroups.com
On Sat, 2008-11-29 at 12:53 -0800, Peng Yu wrote:
> The vim in my system is of version 7.0. I think that it is actually
> because of perl-support that I just installed recently instead of
> perl.vim as I mentioned in the original post.
>
> http://www.vim.org/scripts/script.php?script_id=556
>
> Is it considered a bug of perl-support?
>

My version of vim is 7.1.138 I can't find a version number in perl.vim
so I don't know what version of perl-support you should use.

Here is the top of my perl.vim file:
" Vim syntax file
" Language: Perl
" Maintainer: Nick Hibma <ni...@van-laarhoven.org>
" Last Change: 2006 November 23
" Location: http://www.van-laarhoven.org/vim/syntax/perl.vim

It is actually older than I thought it was.

Tony Mechelynck

unread,
Nov 29, 2008, 6:08:38 PM11/29/08
to vim...@googlegroups.com
On 29/11/08 23:48, Mr. Shawn H. Corey wrote:
> On Sat, 2008-11-29 at 12:53 -0800, Peng Yu wrote:
>> The vim in my system is of version 7.0. I think that it is actually
>> because of perl-support that I just installed recently instead of
>> perl.vim as I mentioned in the original post.
>>
>> http://www.vim.org/scripts/script.php?script_id=556
>>
>> Is it considered a bug of perl-support?
>>
>
> My version of vim is 7.1.138 I can't find a version number in perl.vim
> so I don't know what version of perl-support you should use.
>
> Here is the top of my perl.vim file:
> " Vim syntax file
> " Language: Perl
> " Maintainer: Nick Hibma<ni...@van-laarhoven.org>
> " Last Change: 2006 November 23
> " Location: http://www.van-laarhoven.org/vim/syntax/perl.vim
>
> It is actually older than I thought it was.
>
>

Actually, 'iskeyword' should be set by an ftplugin, not a syntax script
(and by :setlocal, not :set, to avoid clobbering the settings for other
files and the defaults for future new files of a different filetype).
The current $VIMRUNTIME/ftplugin/perl.vim is:

" Vim filetype plugin file
" Language: Perl
" Maintainer: Dan Sharp <dwsharp at hotmail dot com>
" Last Change: 17 Jul 2008
" URL: http://mywebpage.netscape.com/sharppeople/vim/ftplugin

(and my version of Vim is a 7.2.57 which I compiled maybe an hour or so
ago).


Best regards,
Tony.
--
Rule of Creative Research:
(1) Never draw what you can copy.
(2) Never copy what you can trace.
(3) Never trace what you can cut out and paste down.

Mr. Shawn H. Corey

unread,
Nov 29, 2008, 6:24:11 PM11/29/08
to vim...@googlegroups.com
On Sun, 2008-11-30 at 00:08 +0100, Tony Mechelynck wrote:
> Actually, 'iskeyword' should be set by an ftplugin, not a syntax
> script
> (and by :setlocal, not :set, to avoid clobbering the settings for
> other
> files and the defaults for future new files of a different filetype).
> The current $VIMRUNTIME/ftplugin/perl.vim is:
>
> " Vim filetype plugin file
> " Language: Perl
> " Maintainer: Dan Sharp <dwsharp at hotmail dot com>
> " Last Change: 17 Jul 2008
> " URL: http://mywebpage.netscape.com/sharppeople/vim/ftplugin
>
> (and my version of Vim is a 7.2.57 which I compiled maybe an hour or
> so
> ago).

This is mine:


" Vim filetype plugin file
" Language: Perl
" Maintainer: Dan Sharp <dwsharp at hotmail dot com>

" Last Change: 2005 Dec 16
" URL: http://mywebpage.netscape.com/sharppeople/vim/ftplugin


I also found this note:

" The following line changes a global variable but is necessary to make
" gf and similar commands work. The change to iskeyword was incorrect.
" Thanks to Andrew Pimlott for pointing out the problem. If this causes a
" problem for you, add an after/ftplugin/perl.vim file that contains
" set isfname-=:
set isfname+=:
"setlocal iskeyword=48-57,_,A-Z,a-z,:

It is the only part of the file that contains 'iskeyword'

John Beckett

unread,
Nov 29, 2008, 6:56:53 PM11/29/08
to vim...@googlegroups.com
Peng Yu wrote:
> The vim in my system is of version 7.0. I think that it is
> actually because of perl-support that I just installed
> recently instead of perl.vim as I mentioned in the original post.
>
> http://www.vim.org/scripts/script.php?script_id=556
>
> Is it considered a bug of perl-support?

I don't know, but when editing a Perl file, you can see what set isk (iskeyword):

:verbose set isk?

John

Tony Mechelynck

unread,
Nov 29, 2008, 10:55:46 PM11/29/08
to vim...@googlegroups.com

Yeah, I have the same. The default value of 'iskeyword' varies between
Windows and Unix but does not include the colon. Looks like some earlier
versions of the ftplugin "incorrectly" added it.


Best regards,
Tony.
--
OK, so you're a Ph.D. Just don't touch anything.

Reply all
Reply to author
Forward
0 new messages