" Vim syntax file" Language: awk, nawk, gawk, mawk" Maintainer: Antonio Colombo <antonio.colombo@jrc.it>" Last Change: 2002 Jun 23" AWK ref. is: Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger" The AWK Programming Language, Addison-Wesley, 1988" GAWK ref. is: Arnold D. Robbins" Effective AWK Programming, Third Edition, O'Reilly, 2001" MAWK is a "new awk" meaning it implements AWK ref." mawk conforms to the Posix 1003.2 (draft 11.3)" definition of the AWK language which contains a few features" not described in the AWK book, and mawk provides a small number of extensions." TODO:" Dig into the commented out syntax expressions below." For version 5.x: Clear all syntax items" For version 6.x: Quit when a syntax file was already loadedif version < 600syn clearelseif exists("b:current_syntax")finishendif" A bunch of useful Awk keywords" AWK ref. p. 188syn keyword awkStatement break continue delete exitsyn keyword awkStatement function getline nextsyn keyword awkStatement print printf return" GAWK ref. p. 117syn keyword awkStatement nextfile" AWK ref. p. 42, GAWK ref. p. 142-166syn keyword awkFunction atan2 close cos exp fflush int log rand sin sqrt srandsyn keyword awkFunction gsub index length match split sprintf subsyn keyword awkFunction substr system" GAWK ref. p. 142-166syn keyword awkFunction asort gensub mktime strftime strtonum systimesyn keyword awkFunction tolower touppersyn keyword awkFunction and or xor compl lshift rshiftsyn keyword awkFunction dcgettext bindtextdomainsyn keyword awkConditional if elsesyn keyword awkRepeat while forsyn keyword awkTodo contained TODOsyn keyword awkPatterns BEGIN END" AWK ref. p. 36syn keyword awkVariables ARGC ARGV FILENAME FNR FS NF NRsyn keyword awkVariables OFMT OFS ORS RLENGTH RS RSTART SUBSEP" GAWK ref. p. 120-126syn keyword awkVariables ARGIND BINMODE CONVFMT ENVIRON ERRNOsyn keyword awkVariables FIELDWIDTHS IGNORECASE LINT PROCINFOsyn keyword awkVariables RT RLENGTH TEXTDOMAINsyn keyword awkRepeat do" Octal format character.syn match awkSpecialCharacter display contained "\\[0-7]\{1,3\}"syn keyword awkStatement func nextfile" Hex format character.syn match awkSpecialCharacter display contained "\\x[0-9A-Fa-f]\+"syn match awkFieldVars "\$\d\+""catch errors caused by wrong parenthesissyn region awkParen transparent start="(" end=")" contains=ALLBUT,awkParenError,awkSpecialCharacter,awkArrayElement,awkArrayArray,awkTodo,awkRegExp,awkBrktRegExp,awkBrackets,awkCharClasssyn match awkParenError display ")"syn match awkInParen display contained "[{}]"" 64 lines for complex &&'s, and ||'s in a big "if"syn sync ccomment awkParen maxlines=64" Search strings & Regular Expressions therein.syn region awkSearch oneline start="^[ \t]*/"ms=e start="\(,\|!\=\~\)[ \t]*/"ms=e skip="\\\\\|\\/" end="/" contains=awkBrackets,awkRegExp,awkSpecialCharactersyn region awkBrackets contained start="\[\^\]\="ms=s+2 start="\[[^\^]"ms=s+1 end="\]"me=e-1 contains=awkBrktRegExp,awkCharClasssyn region awkSearch oneline start="[ \t]*/"hs=e skip="\\\\\|\\/" end="/" contains=awkBrackets,awkRegExp,awkSpecialCharactersyn match awkCharClass contained "\[:[^:\]]*:\]"syn match awkBrktRegExp contained "\\.\|.\-[^]]"syn match awkRegExp contained "/\^"ms=s+1syn match awkRegExp contained "\$/"me=e-1syn match awkRegExp contained "[?.*{}|+]"" String and Character constants" Highlight special characters (those which have a backslash) differentlysyn region awkString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=awkSpecialCharacter,awkSpecialPrintfsyn match awkSpecialCharacter contained "\\."" Some of these combinations may seem weird, but they work.syn match awkSpecialPrintf contained "%[-+ #]*\d*\.\=\d*[cdefgiosuxEGX%]"" Numbers, allowing signs (both -, and +)" Integer number.syn match awkNumber display "[+-]\=\<\d\+\>"" Floating point number.syn match awkFloat display "[+-]\=\<\d\+\.\d+\>"" Floating point number, starting with a dot.syn match awkFloat display "[+-]\=\<.\d+\>"syn case ignore"floating point number, with dot, optional exponentsyn match awkFloat display "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\>""floating point number, starting with a dot, optional exponentsyn match awkFloat display "\.\d\+\(e[-+]\=\d\+\)\=\>""floating point number, without dot, with exponentsyn match awkFloat display "\<\d\+e[-+]\=\d\+\>"syn case match"syn match awkIdentifier "\<[a-zA-Z_][a-zA-Z0-9_]*\>"" Arithmetic operators: +, and - take care of ++, and --"syn match awkOperator "+\|-\|\*\|/\|%\|=""syn match awkOperator "+=\|-=\|\*=\|/=\|%=""syn match awkOperator "^\|^="" Comparison expressions."syn match awkExpression "==\|>=\|=>\|<=\|=<\|\!=""syn match awkExpression "\~\|\!\~""syn match awkExpression "?\|:""syn keyword awkExpression in" Boolean Logic (OR, AND, NOT)"syn match awkBoolLogic "||\|&&\|\!"" This is overridden by less-than & greater-than." Put this above those to override them." Put this in a 'match "\<printf\=\>.*;\="' to make it not override" less/greater than (most of the time), but it won't work yet because" keywords allways have precedence over match & region." File I/O: (print foo, bar > "filename") & for nawk (getline < "filename")"syn match awkFileIO contained ">""syn match awkFileIO contained "<"" Expression separators: ';' and ','syn match awkSemicolon ";"syn match awkComma ","syn match awkComment "#.*" contains=awkTodosyn match awkLineSkip "\\$"" Highlight array element's (recursive arrays allowed)." Keeps nested array names' separate from normal array elements." Keeps numbers separate from normal array elements (variables).syn match awkArrayArray contained "[^][, \t]\+\["me=e-1syn match awkArrayElement contained "[^][, \t]\+"syn region awkArray transparent start="\[" end="\]" contains=awkArray,awkArrayElement,awkArrayArray,awkNumber,awkFloat" 10 should be enough." (for the few instances where it would be more than "oneline")syn sync ccomment awkArray maxlines=10" define the default highlighting" For version 5.7 and earlier: only when not done already" For version 5.8 and later: only when an item doesn't have highlightling yetif version >= 508 || !exists("did_awk_syn_inits")if version < 508let did_awk_syn_inits = 1command -nargs=+ HiLink hi link <args>elsecommand -nargs=+ HiLink hi def link <args>endifHiLink awkConditional ConditionalHiLink awkFunction FunctionHiLink awkRepeat RepeatHiLink awkStatement StatementHiLink awkString StringHiLink awkSpecialPrintf SpecialHiLink awkSpecialCharacter SpecialHiLink awkSearch StringHiLink awkBrackets awkRegExpHiLink awkBrktRegExp awkNestRegExpHiLink awkCharClass awkNestRegExpHiLink awkNestRegExp KeywordHiLink awkRegExp SpecialHiLink awkNumber NumberHiLink awkFloat FloatHiLink awkFileIO Special"HiLink awkOperator Special"HiLink awkExpression SpecialHiLink awkBoolLogic SpecialHiLink awkPatterns SpecialHiLink awkVariables SpecialHiLink awkFieldVars SpecialHiLink awkLineSkip SpecialHiLink awkSemicolon SpecialHiLink awkComma Special"HiLink awkIdentifier IdentifierHiLink awkComment CommentHiLink awkTodo Todo" Change this if you want nested array names to be highlighted.HiLink awkArrayArray awkArrayHiLink awkArrayElement SpecialHiLink awkParenError awkErrorHiLink awkInParen awkErrorHiLink awkError Errordelcommand HiLinkendiflet b:current_syntax = "awk"" vim: ts=8