sh/bash syntax highlighting broken (sometimes) for comments.
Maintainer antworten meist innerhalb von 13 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 57/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- bash, shell, vim
- Bereich
- developer-experience
Rechercherichtung
The highlighting rules live in runtime/syntax/sh.vim; start by reading the shComment definitions and the regions that contain them (the if/then block and command-name matching for echo), since the false match appears only where those clusters apply. Reproduce with the sample script saved as a file and opened via vim --clean file.sh, then narrow the trigger line by line. Check src/testdir/test_syntax.vim for how syntax regressions are asserted, and treat "no line after # highlighted" on the sample as done.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Steps to reproduce
open this file with vim and see that the syntax highlighting sometimes consider the text after # to be a comment and sometimes not:
#!/bin/sh
# only echo seems to be affected
echo hello# world
printf hello# world
foo hello# world
# these only are affected within an `if` statement?
foo "$@"# || uhoh
foo-bar "$@"# || uhoh
if true; then
foo "$@"# || uhoh
foo-bar "$@"# || uhoh
fi
in the above script there are actually 0 inline comments according to bash - it just looks like there are according to vim.
attached is a screenshot of this file in vim --clean, notice that it falsely highlights inline comments for echo, or when inside the if block:
Note I originally found this when testing a bash script but it appears to affect sh as well.
Expected behaviour
I expect that none of the lines in the above script will have any inline comments highlighted.
Version of Vim
9.2 1-1393
Environment
OS: macOS 27.0.1, vim installed with homebrew
$ uname
Darwin
$ echo $TERM
xterm-256color
$ echo $0
-bash
$ type vim
vim is hashed (/opt/homebrew/bin/vim)
$ vim --version
VIM - Vi IMproved 9.2 (2026 Feb 14, compiled Nov 22 2026 20:28:41)
macOS version - arm64
Included patches: 1-1393
Compiled by Homebrew
Huge version without GUI. Features included (+) or not (-):
+acl +find_in_path -mouseshape -tag_old_static
+arabic +float +multi_byte -tcl
+autochdir +folding +multi_lang +termguicolors
+autocmd -footer -mzscheme +terminal
-autoservername +fork() +netbeans_intg +terminfo
-balloon_eval +gettext +num64 +termresponse
+balloon_eval_term -hangul_input +packages +textobjects
-browse +iconv -pango +textprop
++builtin_terms -image +path_extra +timers
+byte_offset -image_popup +perl +title
+channel +insert_expand +persistent_undo -toolbar
+cindent +ipv6 +popupwin +user_commands
+clientserver +job +postscript +vartabs
+clipboard +jumplist +printer +vertsplit
+clipboard_provider +keymap +profile +vim9script
+cmdline_compl +lambda -python +viminfo
+cmdline_hist +langmap +python3/dyn +virtualedit
+cmdline_info +libcall +quickfix +visual
+comments +linebreak +reltime +visualextra
+conceal +lispindent +rightleft +vreplace
+cryptv +listcmds +ruby/dyn -wayland
+cscope +localmap +scrollbind -wayland_clipboard
+cursorbind +lua/dyn +signs +wildignore
+cursorshape +menu +smartindent +wildmenu
+dialog_con +mksession +socketserver +windows
+diff +modify_fname +sodium +writebackup
+digraphs +mouse +sound -X11
-dnd +mouse_dec +spell -xattr
-ebcdic -mouse_gpm +startuptime -xfontset
+emacs_tags -mouse_jsbterm +statusline -xim
+eval +mouse_netterm -sun_workshop -xpm
+ex_extra +mouse_sgr +syntax -xsmp
+extra_search -mouse_sysmouse +tabpanel -xterm_clipboard
-farsi +mouse_urxvt -tag_any_white -xterm_save
+file_in_path +mouse_xterm +tag_binary
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
3rd user vimrc file: "~/.config/vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/opt/homebrew/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X -DMACOS_X_DARWIN -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang -Wl,-rpath,@loader_path/../../../../opt/lua/lib -Wl,-rpath,@loader_path/../../../../opt/[email protected]/lib -Wl,-rpath,@loader_path/../../../../opt/ruby/lib -o vim -lm -lncurses -lsodium -liconv -lintl -framework AppKit -fstack-protector-strong -L/System/Library/Perl/5.34/darwin-thread-multi-2level/CORE -lperl
$
the sh syntax file said it was looking for a maintainer so hopefully opening the issue here is the right place.
- Vorherrschende Sprache
- Vim Script
- Sterne
- 41.4k
- Forks
- 6.2k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus vim/vim
-
autoconf failes to find libsodium even when present due to implicit function declarationEvtl. vergeben @coderjoe hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 13 Tagen
-
`json_decode()` uses a number as a string pointer when 'encoding' has no converterEvtl. vergeben @mattn hat das vor 7 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 13 Tagen
-
GTK4 build's v:servername is prefixed with $XDG_RUNTIME_DIR/vimEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
vim/vim#21624 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 13 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 13 Tagen
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
vim/vim#21204 · 14 Kommentare ·
Maintainer antworten meist innerhalb von 13 Tagen
Ähnliche Issues
-
Needs Triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
-
enhancement good first issue help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 90/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 78/100
anthropics/skills#2328 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
tonydzi/sqlite-graph-memory#133 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
area: build-and-ci S3: minor
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
manaflow-ai/cmux#72257 ·
Maintainer antworten meist innerhalb von 1 Tag