简体   繁体   中英

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:

看这里

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM