6

I use, e.g., dw to delete a word based on word boundaries defined by changing character classes, so that this command applied on abc,def,ghi will result in ,def,ghi. (So far so good, and it worked for me for decades.) Now, since just recently, that does not work any more on dots (.); that dw command applied on abc.def;ghi will result in ;ghi.

Can anyone explain what happens here; maybe whether I changed some setting by accident. - How can that misbehaviour be fixed?

Update: Following Peter's hint in his answer I obtained:

  iskeyword=@,48-57,_,192-255,.
        Last set from /usr/share/vim/vim73/syntax/sh.vim

and found this content in /usr/share/vim/vim73/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 prevent/override
" its setting.
if exists("g:sh_isk")          " override support
 exe "setlocal isk=".g:sh_isk
elseif !exists("g:sh_noisk")   " prevent modification support
 setlocal isk+=.
endif

Now this seems to be a system setting. I have no reservations against changing that file - only that it will be changed again on system updates, I fear. But since I am not familiar with vim's script language I'd be interested to know what the correct way to fix it would be. Personally I'd just remove the . so that the += becomes a no-op, but I guess the whole if statement need to be fixed. (What's that "g:sh_noisk"?)

9

Sounds like 'iskeyword' changed recently. You can do :verbose set iskeyword? to see where 'iskeyword' was last set.

Your specific issue is with the sh filetype. Here is an excerpt from :h g:sh_isk:

The shell languages appear to let "." be part of words, commands, etc;
consequently it should be in the isk for sh.vim.  As of v116 of syntax/sh.vim,
syntax/sh.vim will append the "." to 'iskeyword' by default; you may control
this behavior with:
    let g:sh_isk  = '..whatever characters you want as part of iskeyword'
    let g:sh_noisk= 1  " otherwise, if this exists, the isk will NOT chg

According to this you will need to add the following to your vimrc:

let g:sh_noisk = 1

For more help see:

:h 'iskeyword'
:h :set-verbose
:h local-options
:h g:sh_isk
:h ft-sh-syntax

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.