0

There are several questions here on how to use different syntax highlighting within heredocs, but I want to just disable it. I can expand upon any answers I get here for other syntaxes within other filetypes.

I want to disable syntax highlighting in heredocs with these matches at the start:

cat << EOF
cat <<-EOF

I have come up with this, but obviously it doesn't work:

# after/syntax/sh.vim
syntax region hereDocText matchgroup=Statement start=+<<[-\s]*EOF end=+^EOF contains=NONE
2
  • can you clarify what you mean by disable, and why? the region needs to be highlighted as something and it isn't sh script. what would it look like upon disabling?
    – Mass
    Nov 13, 2022 at 15:14
  • @Mass As in no syntax highlighting within the heredoc. I am usually using plain English within the heredocs and it's especially annoying when there is an apostrophe that screws up the syntax highlighting on the rest of the script.
    – paradroid
    Nov 13, 2022 at 15:26

1 Answer 1

1

You have malformed syntax command, following one should work:

syntax region hereDocText matchgroup=Statement start=+<<[-[:space:]]*EOF+ end=+^EOF+ contains=NONE

enter image description here

5
  • Thanks, but for some reason it's not working for me. I can see that the after/syntax/sh.vim has loaded in :script, but it's not making any difference.
    – paradroid
    Nov 13, 2022 at 16:39
  • I don't understand what matchgroup is for and I have not defined it anywhere else, if that makes a difference.
    – paradroid
    Nov 13, 2022 at 16:43
  • @paradroid asciinema.org/a/ZY1OGWo6Z6eWZjTViipcOcyx0
    – Maxim Kim
    Nov 13, 2022 at 17:31
  • @paradroid matchgroup is the name of the highlight group to apply to whatever was matched by start and end regexes.
    – Maxim Kim
    Nov 13, 2022 at 17:31
  • Thanks. I still cannot get it to work at the moment, but this is clearly a separate issue.
    – paradroid
    Nov 15, 2022 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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