Thanks for your reply. If I understand correctly you are suggesting to hard-configure the "used shell" by, say, let g:is_kornshell= 1
But this (as it appears to me) would not be an appropriate solution to the problem. The setting should not be depending on a single shell type that a user has to specify. It shall depend on the actual shell *necessary* to parse _the given source codes_. I am actually using different shells; sh (POSIX), bash (from others), and ksh (preferred). All files should be correctly highlighted. And ideally by an heuristic, not by forcing the user to change the operated items. But the (existing) heuristics seems not be sufficient. (And, BTW, it's not about "mind-reading". - It's about keywords and syntax-reading.) What I seem to currently have to do is either to explicitly set the syntax (ex-command), or to specify a shebang line on each file (whether mine or third party), or maybe add (or change) the file extension. - Usually I don't want (or am not allowed) to change the file contents or its name. All that is of course aside from the actual inherent issues with shell highlighting in Vim that have been detected. Janis ________________________________________ Von: [email protected] <[email protected]> im Auftrag von Charles Campbell <[email protected]> Gesendet: Sonntag, 7. Juni 2026 15:12 An: [email protected] Betreff: Re: AW: Highlighting problem with ksh syntax Janis Papanagnou wrote: > Hi Christian, > > thanks for the explanation/history. - Some remarks below... > >> On Do, 28 Mai 2026, Janis Papanagnou wrote: >> >>> I just cloned https://github.com/vim/vim.git >>> >>> I copied the various existing files bash.vim, sh.vim, zsh.vim >>> (which I'm interested in) below my local $HOME/.vim >>> into their respective directories syntax, indent, and ftplugin . >>> >>> Opening a local test file that contains (besides other things) >>> >>> if [[ "$1" = "$2" ]] >>> ... >>> x=$'\v' >> Traditionally, the vim sh filetype supports only the very narrow >> traditional (Bourne) syntax, not Bash, not ksh and not even POSIX >> syntax. >> >> However there were a few complaints over time, so a few heuristics have >> been built into the sh syntax script, which tries to guess what sh >> dialect is in use, e.g. by setting global variables or by inspecting the >> shebang line. >> >> I believe the above is not valid Bourne shell syntax, that's why you see >> those errors. > Yes, that is correct. (Actually Bourne shell 'sh' is meaningless nowadays. > The minimum expected standard is the POSIX Shell 'sh', based on ksh88.) > The sh.vim syntax file was written to cover three types: ksh, bash, sh, and was extended to handle dash. There are various ways that sh.vim attempts to infer which shell the user actually wanted. However, this process is likely to fail to be a good mind reader, and so things like: let g:is_kornshell= 1 let g:is_bash= 1 let g:is_posix= 1 placed in your .vimrc will get sh.vim to do what you want. The reason why it defaults to Bourne shell (sh) is to encourage users to specify what they actually tend to use. In my experience, nearly half of the users use bash and near half use kornshell/posix. There are plenty of people that feel that their choice should be made the default; since bash/posix/ksh share a lot of non-Bourne features about half will be satisfied and the other half will be constantly issuing bug reports. Chip Campbell -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/3d7aa4be-ee65-faf0-bd05-51daff280d37%40gmail.com. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/AS8PR02MB10409E1E8C3A0F9FC7F08C56DF31B2%40AS8PR02MB10409.eurprd02.prod.outlook.com.
