Home > Blockchain >  VIM 9 Word boundary Change for Perl files
VIM 9 Word boundary Change for Perl files

Time:09-23

In vim 8, if you had the following string:

package Some::Package::Name;

and you placed your cursor on the S in Some::Package::Name and did a cw it would replace the text Some with whatever you typed.

In vim 9, cw now changes from S to the e in Name.

That behavior is probably due to a change in

/usr/share/vim/vim90/syntax/perl.vim  

Muscle memory is hard to change, and I would prefer if I could revert back to Vim8 behavior. I've looked at the syntax file above and I am at a complete loss on how to change it.

Does anyone know how I can override this change in my vimrc?

My .vimrc remained unchanged between vim8 and vim9. With the following perl relevant sections:

au BufRead,BufNewFile *.pm set filetype=perl
au BufRead,BufNewFile *.t set filetype=perl
let g:ale_perl_perl_executable = '/opt/perl/bin/perl'
let g:ale_perl_perl_options = '-c -Mwarnings -Ilib -I/opt/perl/lib'
let b:ale_linters = { 'perl': [ 'perl' ] }
let g:ale_sign_column_always = 1

CodePudding user response:

No, the built-in syntax script has nothing to do with this.

It's the built-in filetype plugin:

$VIMRUNTIME/ftplugin/perl.vim

that adds : to :help 'iskeyword', which is the option that tells Vim, among other things, where the next "word" start:

setlocal iskeyword =:

In short, it tells Vim that : is part of the current word so cw skips it because it is not considered a separator anymore.

That setting was apparently added 9 years ago.

If you don't want it, you can create this file:

~/.vim/after/ftplugin/perl.vim

with this content:

setlocal iskeyword-=:

which is sourced after the built-in filetype plugin and thus overrides whatever option you set in it.

CodePudding user response:

I'm one of the maintainers of the vim-perl project, which is what feeds vim the syntax files.

You say

If you placed your cursor on the S in Some::Package::Name and did a cw it would replace the text Some with whatever you typed.

In vim 9, cw now changes from S to the e in Name.

I am not seeing that behavior that you describe for vim 9. I suspect that there may be something else that changed in vim 9 that is interfering with that.

I think a better place to figure out why that is would be to create an issue in the vim-perl project describing the problem, and we'll see what we can do to help you figure it out.

  • Related