3

When I edit VIM syntax highlighting definitions or any other VIM script file (*.vim), I lose syntax highlighting on lines that are continued from the previous one. For example,

syntax region LongRegionNameToTakeUpSpaceOnThisLine matchgroup=String
\   oneline contained start=+"+ end=+"+ skip=+\\"+
\   contains=Foo,Bar containedin=AnotherRegion

should have full syntax highlighting for all three lines (i.e., "contains," "containedin," "skip," "start," "end," "oneline," and "contained" should all be highlighted as key words, just like "matchgroup" is). Instead, I only get highlighting on the first line.

Does this happen for other users, too, or is it specific to my installation or something in my settings? I can confirm that it is still not working if I don't source my vimrc (e.g., "vim -u NONE test.vim").

This used to work in VIM 7.3 (on Fedora), but VIM 7.4 (Ubuntu 16.04.6), VIM 8.2 (Fedora 34), and VIM 9.0 (Fedora 35) don't work correctly for me unless I fall back to an old syntax definition file (vim.vim). I can't find anything really obvious in the syntax definition files that changed for the linecont code.

10
  • 1
    It seems to work for me in Vim 9.0.35 if I put just that snippet in a new file: i.stack.imgur.com/5qhji.png – it could be there's something else in the file that confuses things; does it work if you have a file with only that snippet? Also, which patch version are you using (the second line of output in :version). Jul 27, 2022 at 8:29
  • 1
    You can also try using the command at the top of this answer to see if anything matches. Jul 27, 2022 at 8:44
  • 1
    @MartinTournoij 9.0.57 and vim -u DEFAULTS -U NONE, paste, :setf vim and the highlight is wrong until I join the continued lines. OTOH, a random script in my dotfiles with line continuations works fine.
    – D. Ben Knoble
    Jul 27, 2022 at 14:56
  • 1
    Interesting; I installed 9.0.57 and did exactly the same as your instructions @D.BenKnoble, and it still works for me. Jul 27, 2022 at 15:40
  • 1
    @MartinTournoij Looking at your PNG, it seems to me that it's not working, since I'd expect the "oneline", "contained", "start", "end", "skips", "contains" and "containedin" all to highlight the same as "matchgroup", but you can clearly see they're different. If you join the three lines, you'll see it will update the highlighting of those keywords.
    – filbranden
    Jul 27, 2022 at 22:03

0

Your Answer

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

Browse other questions tagged or ask your own question.