4

I write many scripts where there is complex awk logic incorporated into the script directly. I prefer the "one-stop-shop" approach and not have those logic segments as external files.

I have tried what I have seen in this reference about specifying the multiple syntaxes that are to be evaluated (and hopefully colorized per syntax colorscheme). I tried the suggested method as both a VIM command and as a setting in the .vimrc file. The use of "setfiletype sh.awk.sed" did not work in either case.

Is there a special way to make this work properly ?

Another reference seems to provide what looks like awk-related syntax declarations. However, those are presented out of context, and it is not clear if the info provided is complete and self-contained, or whether that is an extract from an unknown, unpublished larger syntax definition, and whether that is added to the sh.vim or the awk.vim syntax files ?

Can anyone shed light on this ?

This first image is a test file created to show my colorscheme use-cases for Bourne shell.

first image

This second image is a sample of awk logic displayed by the same scheme.

second image

Eric Marceau
  • 1,601
  • 1
  • 8
  • 11
  • 3
    [How do I navigate topics in Vims documentation](https://vi.stackexchange.com/questions/2136/how-do-i-navigate-to-topics-in-vims-documentation). `:h sh-awk`. – Matt Apr 17 '21 at 07:46
  • starting with the first BEGIN, put all that in a filename.awk file and try vim on that. It is getting confused by the " and ' on multiple lines – Andrew Aug 19 '21 at 15:40
  • Thank you, Andrew. When I worked professionally within a project team, I've done that a lot because that was the team preference. My own preference for coding applicable to my desktop environment is to keep each task-oriented script as standalone and self-contained as possible, keeping it all together. I read somewhere that Vim is supposed to handle multiple syntax simultaneously. However, I haven't found any references outlining how to make that happen for bourne/bash shell and awk, which I have come to rely on more than in the past. Any guidance on making that work would be appreciated. – Eric Marceau Aug 22 '21 at 22:57
  • @Eric Does this help?: https://vi.stackexchange.com/questions/31896/how-to-syntax-highlight-part-of-a-file-in-a-foreign-language – Andrew Feb 26 '22 at 19:53

0 Answers0