This comes down to the
iskeyword setting. When I run
:set iskeyword? in a bash file, I get this:
When I run the same command with a python file, I get this:
If you have the filetype plugin set up, you could add this to your python file:
or this to your bash file (depending on which way you want it):
If you don't have the filetype plugin set up, you can achieve this with autocommands. For example:
autocmd BufReadPre *.py set iskeyword+=.
autocmd BufReadPre *.sh set iskeyword-=.
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
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
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
.vimrc, you can override this setting.