awk mode



  • I recently downloaded gawk, since I have been without an awk for a couple years now, and it has been painful.

    But there are problems I don’t know how to solve

    • I put a list item for an awk function in “keyword list, first group”, such as “substr”. I set the style to boldface, What I see is
      substr(…)
      when I expect to see
      substr(…)
      If I put a space after the word, then I see
      substr (…)
      but I want the highlight whether the word has a space or an open paren

    • Simularly, if I have “next” as a keyword, I see
      next}
      when I expect to see
      next}
      Again, adding the space makes it work
      next }
      I need to specify “words followed by a delimiter”

    • Apparently, I can have only one line-comment convention; I chose the traditional “#” “\” “”, indicating, I think, that “\” followed immediately by a newline continues the line comment onto the next line. But gawk allows C-style line comments, e.g. // text

    • I want the regular expressions in a controlled presentation. So I go to operators and delimiters, and choose “/” “\” “/” and italic format. It looks great; I see
      /pattern/
      and even
      /<\/v>/
      where that apparently super-capital V is actually a “\” followed by a “/”. But now it fails, if I write
      /<\/v>/ { sub (/<\/v>/, “”, $0)
      …other stuff}
      it does not properly escape it, and while I expected
      /<\/v>/ {sub (/<\v>/, “”, $0)
      instead I get
      /<\/v>/ { sub (/<\/v>/, “”, $0)
      …other stuff}

      /<\/k>/ { printing = 1
      …other stuff }

      So why didn’t the “escape” specification work for the second pattern?

    • I want it to be the case that if I hit enter and the previous nonblank character is } that it puts me at the start of the line, but if the previous nonblank character is anything else, I want it to indent to under the first “executable” character in the previous line, that is,

    /text/    { print $0 }
    |<- metacomment: caret ends up here
                         |<-metacomment: brace on same line
                         |  as open brace left untouched
    /text/    { sub(...)
                |<- metacomment: caret ends up here
               } <- metacomment: bare brace on line is aligned
                    with open brace
    Short of writing a plugin extension, how would this be done?
    

    and now the parity is wrong, so my regexes are in normal font and everything else is italicized. Apparently it did not understand the second escape character as being an escape



  • @Joseph-Newcomer

    UDL has its limitations, one way to overcome those is to use a script like this.

    Is your gawk udl available for download if one wants to make some tests?


Log in to reply