Tim Menzies
Tim Menzies

Reputation: 730

What vimrc settings control syntax highlighting of indented awk code in markdown?

I cannot get indented code to highlight in GAWK in vim markdown model

Context: I doing some literature programming in gawk. Comments are markdown syntax and code is GAWK, indented by a tab spaces.

Problem: I followed the doc at https://github.com/plasticboy/vim-markdown#options. The markdown highlights as it should but the indented code remains white and bland:

see here

What I did: The first line of my source code is

# vim: nospell filetype=markdown  :

My .vimrc contains the line

let g:vim_markdown_fenced_languages = ['awk=awk']

Which, according to the doc at SHOULD be enough to make that syntax highlight happen

Help?

Upvotes: 2

Views: 924

Answers (1)

jeremysprofile
jeremysprofile

Reputation: 11474

That information is not enough to get vim to understand how to highlight your block of code. "Fenced" refers to code that is bounded by triple backticks as follows:

```awk
this is some awk code that would be highlighted
```

This, when combined with the let g:vim_markdown_fenced_languages = ['awk', 'sh', 'make'] etc lists, lets vim know exactly which highlighting syntax to use in a particular block.

You should also note that you don't need that particular vim plugin to get this to work; this is native vim functionality.


Edit: If you really want indentation, you can just indent the code block with the fencing:

    ```awk
    some awk code surrounded by indented fencing would be highlighted
    ```

If you were really hard-pressed to avoid the fencing entirely, the only way I know of would be to go into the actual vim syntax files:

cd $(vim -Nesc '!echo $VIMRUNTIME' -c qa)
vim syntax/markdown.vim

and try to figure out a way to force a default of awk highlighting on indented code, but I wouldn't recommend it.

Upvotes: 4

Related Questions