This comes down to the iskeyword
setting. When I run :set iskeyword?
in a bash file, I get this:
iskeyword=@,48-57,_,192-255,.
When I run the same command with a python file, I get this:
iskeyword=@,48-57,_,192-255
If you have the filetype plugin set up, you could add this to your python file:
set iskeyword+=.
or this to your bash file (depending on which way you want it):
set iskeyword-=.
If you don't have the filetype plugin set up, you can achieve this with autocommands. For example:
autocmd BufReadPre *.py set iskeyword+=.
or
autocmd BufReadPre *.sh set iskeyword-=.
Updated answer:
Do you have any idea why? Historical reasons? Some kind of POSIX thing? Should we ask Bram Moolenaar itself?
Actually, we have the most authoritative answer you could possibly get. :)
If you run :scriptnames
you can see a list of all the files that vim has loaded this particular session. Somewhere in there you'll see $VIMRUNTIME/syntax/sh.vim
.
This is not because of Bram Moolenaar, however the author did leave his name on the file. The reason this setting is on is because of "Charles E. Campbell". Here is some relevant code and even reasoning behind the settings from that file:
" Vim syntax file
" Language: shell (sh) Korn shell (ksh) bash (sh)
" Maintainer: Charles E. Campbell <[email protected]>
" Previous Maintainer: Lennart Schultz <[email protected]>
" Last Change: Jul 02, 2013
" Version: 131
" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
" For options and settings, please use: :help ft-sh-syntax
" This file includes many ideas from ?ric Brunet ([email protected])
...
" AFAICT "." should be considered part of the iskeyword. Using iskeywords in
" syntax is dicey, so the following code permits the user to
" g:sh_isk set to a string : specify iskeyword.
" g:sh_noisk exists : don't change iskeyword
" g:sh_noisk does not exist : (default) append "." to iskeyword
if exists("g:sh_isk") && type(g:sh_isk) == 1 " user specifying iskeyword
exe "setl isk=".g:sh_isk
elseif !exists("g:sh_noisk") " optionally prevent appending '.' to iskeyword
setl isk+=.
endif
So actually, my previous recommendation of autocmd BufReadPre *.sh set iskeyword-=.
is not the ideal way to fix it. If you put
let g:sh_noisk = 1
to your .vimrc
, you can override this setting.