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

4
  • 3
    How do I navigate topics in Vims documentation. :h sh-awk. Commented Apr 17, 2021 at 7: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 Commented Aug 19, 2021 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. Commented Aug 22, 2021 at 22:57
  • @Eric Does this help?: vi.stackexchange.com/questions/31896/… Commented Feb 26, 2022 at 19:53

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.