Search code examples
perlvimvim-perl

VIM 9 Word boundary Change for Perl files


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

Solution

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