I recently came to know that we can use

<!-- language-all: bash -->


<!-- language: bash -->

for manually adding syntax highlighting. It is also mentioned in: https://unix.stackexchange.com/editing-help#syntax-highlighting

I feel question using tags like text-processing, sed, awk, grep, etc but not bash could use syntax highlighting by default, instead of manual addition

Note: It need not be bash as such, anything suitable

Here's an example without syntax highlighting and one with bash syntax added

with and without syntax highlighting example

  • 1
    What syntax though? Mods can associate language styles to tags, but which one would we use for text-processing? How can we know what tool an answer would use? And what highlighting would make sense for sed? C can work for awk but what would make sense for grep?
    – terdon Mod
    Dec 6, 2017 at 13:37
  • @terdon I've added a snapshot.. it is more of command line syntax than language syntax..
    – Sundeep
    Dec 6, 2017 at 14:20
  • 1
    Try it with grep '#' file though. Or grep foo | perl -pe ... etc which breaks both of them. It's kinda tricky to get right.
    – terdon Mod
    Dec 6, 2017 at 14:23
  • agree, it will not work good for all cases.. but that case already happens when bash is also tagged for those questions that have answers given with sed/grep/awk/etc.. if adding code block had usage like triple backtick plus language name (like used in github) it would be easier to simply add/change language.. anyway just thought this would help
    – Sundeep
    Dec 6, 2017 at 14:34

1 Answer 1


For your trivial examples, syntax highlighting looks mildly good because they have short strings in them highlighted as such. But for most text I have seen, blanket-wrapping all awk or sed code (especially those that are even mildly complex) as a string is useless. It might as well not be highlighted at all.

Not only that, most of the actual text given as examples for processing have no meaningful application of bash syntax highlighting at all. In many cases, they just simply highlight random words and add noise to the text, making a visual parsing of it harder.

So, if highlighting was applied to the entire post because of a tag, at best they're mostly useless, at worst they're actively harming readability. I'd rather not have any syntax highlighting applied of these by default. If you need to highlight a command, highlight it using <!-- language: ... -->.

By the way, awk code can be syntax highlighted as awk, but not if it's wrapped in quotes:

<!-- language: lang-awk -->

    BEGIN {
       if ($0 ~ /foo/)
           print "foo"

enter image description here

So, if anything, should be highlighted with that.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .