Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
awk.vim218 linesDownload Raw Back to syntax
1" Vim syntax file2" Language:		awk, nawk, gawk, mawk3" Maintainer:		Doug Kearns <dougkearns@gmail.com>4" Previous Maintainer:	Antonio Colombo <azc100@gmail.com>5" Last Change:		2024 Oct 286 7" AWK  ref. is: Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger8" The AWK Programming Language, Addison-Wesley, 19889 10" GAWK ref. is: Arnold D. Robbins11" Effective AWK Programming, Third Edition, O'Reilly, 200112" Effective AWK Programming, Fourth Edition, O'Reilly, 201513" (up-to-date version available with the gawk source distribution)14 15" MAWK is a "new awk" meaning it implements AWK ref.16" mawk conforms to the Posix 1003.2 (draft 11.3)17" definition of the AWK language which contains a few features18" not described in the AWK book, and mawk provides a small number of extensions.19 20" TODO:21" Dig into the commented out syntax expressions below.22 23" Quit when a syntax file was already loaded24if exists("b:current_syntax")25  finish26endif27 28let s:cpo_save = &cpo29set cpo&vim30 31syn iskeyword @,48-57,_,192-255,@-@32 33" A bunch of useful Awk keywords34" AWK  ref. p. 18835syn keyword awkStatement	break continue delete exit36syn keyword awkStatement	function getline next37syn keyword awkStatement	print printf return38" GAWK ref. Chapter 7-939syn keyword awkStatement	case default switch nextfile40syn keyword awkStatement	func41" GAWK ref. Chapter 2.7, Including Other Files into Your Program42" GAWK ref. Chapter 2.8, Loading Dynamic Extensions into Your Program43" GAWK ref. Chapter 15, Namespaces44" Directives45syn keyword awkStatement	@include @load @namespace46"47" GAWK ref. Chapter 9, Functions48" Numeric Functions49syn keyword awkFunction	atan2 cos exp int log rand sin sqrt srand50" String Manipulation Functions51syn keyword awkFunction	asort asorti gensub gsub index length match 52syn keyword awkFunction	patsplit split sprintf strtonum sub substr53syn keyword awkFunction	tolower toupper54" Input Output Functions55syn keyword awkFunction	close fflush system56" Time Functions57syn keyword awkFunction	mktime strftime systime58" Bit Manipulation Functions59syn keyword awkFunction	and compl lshift or rshift xor60" Getting Type Information Functions61syn keyword awkFunction	isarray typeof62" String-Translation Functions63syn keyword awkFunction	bindtextdomain dcgettext dcngetext64 65syn keyword awkConditional	if else66syn keyword awkRepeat	while for do67 68syn keyword awkTodo	contained TODO69 70syn keyword awkPatterns	BEGIN END BEGINFILE ENDFILE71 72" GAWK ref. Chapter 773" Built-in Variables That Control awk74syn keyword awkVariables        BINMODE CONVFMT FIELDWIDTHS FPAT FS75syn keyword awkVariables	IGNORECASE LINT OFMT OFS ORS PREC76syn keyword awkVariables	ROUNDMODE RS SUBSEP TEXTDOMAIN77" Built-in Variables That Convey Information78syn keyword awkVariables	ARGC ARGV ARGIND ENVIRON ERRNO FILENAME79syn keyword awkVariables	FNR NF FUNCTAB NR PROCINFO RLENGTH RSTART 80syn keyword awkVariables	RT SYMTAB81 82" Arithmetic operators: +, and - take care of ++, and --83syn match   awkOperator		"+\|-\|\*\|/\|%\|="84syn match   awkOperator		"+=\|-=\|\*=\|/=\|%="85syn match   awkOperator		"\^\|\^="86 87" Octal format character.88syn match   awkSpecialCharacter display contained "\\[0-7]\{1,3\}"89" Hex   format character.90syn match   awkSpecialCharacter display contained "\\x[0-9A-Fa-f]\+"91 92syn match   awkFieldVars	"\$\d\+"93 94" catch errors caused by wrong parenthesis95syn region	awkParen	transparent start="(" end=")" contains=ALLBUT,awkParenError,awkSpecialCharacter,awkArrayElement,awkArrayArray,awkTodo,awkRegExp,awkBrktRegExp,awkBrackets,awkCharClass96syn match	awkParenError	display ")"97"syn match	awkInParen	display contained "[{}]"98 99" 64 lines for complex &&'s, and ||'s in a big "if"100syn sync ccomment awkParen maxlines=64101 102" Search strings & Regular Expressions therein.103syn region  awkSearch	oneline start="^[ \t]*/"ms=e start="\(,\|!\=\~\)[ \t]*/"ms=e skip="\\\\\|\\/" end="/" contains=awkBrackets,awkRegExp,awkSpecialCharacter104syn region  awkBrackets	contained start="\[\^\]\="ms=s+2 start="\[[^\^]"ms=s+1 end="\]"me=e-1 contains=awkBrktRegExp,awkCharClass105syn region  awkSearch	oneline start="[ \t]*/"hs=e skip="\\\\\|\\/" end="/" contains=awkBrackets,awkRegExp,awkSpecialCharacter106 107syn match   awkCharClass	contained "\[:[^:\]]*:\]"108syn match   awkBrktRegExp	contained "\\.\|.\-[^]]"109syn match   awkRegExp	contained "/\^"ms=s+1110syn match   awkRegExp	contained "\$/"me=e-1111syn match   awkRegExp	contained "[?.*{}|+]"112 113" String and Character constants114" Highlight special characters (those which have a backslash) differently115syn region  awkString	start=+"+  skip=+\\\\\|\\"+  end=+"+  contains=@Spell,awkSpecialCharacter,awkSpecialPrintf116syn match   awkSpecialCharacter contained "\\."117 118" Some of these combinations may seem weird, but they work.119syn match   awkSpecialPrintf	contained "%[-+ #]*\d*\.\=\d*[cdefgiosuxEGX%]"120 121" Numbers, allowing signs (both -, and +)122" Integer number.123syn match  awkNumber		display "[+-]\=\<\d\+\>"124" Floating point number.125syn match  awkFloat		display "[+-]\=\<\d\+\.\d+\>"126" Floating point number, starting with a dot.127syn match  awkFloat		display "[+-]\=\<.\d+\>"128syn case ignore129"floating point number, with dot, optional exponent130syn match  awkFloat	display "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\>"131"floating point number, starting with a dot, optional exponent132syn match  awkFloat	display "\.\d\+\(e[-+]\=\d\+\)\=\>"133"floating point number, without dot, with exponent134syn match  awkFloat	display "\<\d\+e[-+]\=\d\+\>"135syn case match136 137"syn match  awkIdentifier	"\<[a-zA-Z_][a-zA-Z0-9_]*\>"138 139" Comparison expressions.140syn match   awkExpression	"==\|>=\|=>\|<=\|=<\|\!="141syn match   awkExpression	"\~\|\!\~"142syn match   awkExpression	"?\|:"143syn keyword awkExpression	in144 145" Boolean Logic (OR, AND, NOT)146syn match  awkBoolLogic	"||\|&&\|\!"147 148" This is overridden by less-than & greater-than.149" Put this above those to override them.150" Put this in a 'match "\<printf\=\>.*;\="' to make it not override151" less/greater than (most of the time), but it won't work yet because152" keywords always have precedence over match & region.153" File I/O: (print foo, bar > "filename") & for nawk (getline < "filename")154"syn match  awkFileIO		contained ">"155"syn match  awkFileIO		contained "<"156 157" Expression separators: ';' and ','158syn match  awkSemicolon	";"159syn match  awkComma		","160 161syn match  awkComment	"#.*" contains=@Spell,awkTodo162 163syn match  awkLineSkip	"\\$"164 165" Highlight array element's (recursive arrays allowed).166" Keeps nested array names' separate from normal array elements.167" Keeps numbers separate from normal array elements (variables).168syn match  awkArrayArray	contained "[^][, \t]\+\["me=e-1169syn match  awkArrayElement      contained "[^][, \t]\+"170syn region awkArray		transparent start="\[" end="\]" contains=awkArray,awkArrayElement,awkArrayArray,awkNumber,awkFloat171 172" 10 should be enough.173" (for the few instances where it would be more than "oneline")174syn sync ccomment awkArray maxlines=10175 176" Define the default highlighting.177hi def link awkConditional	Conditional178hi def link awkFunction		Function179hi def link awkRepeat		Repeat180hi def link awkStatement	Statement181hi def link awkString		String182hi def link awkSpecialPrintf	Special183hi def link awkSpecialCharacter	Special184hi def link awkSearch		String185hi def link awkBrackets		awkRegExp186hi def link awkBrktRegExp	awkNestRegExp187hi def link awkCharClass	awkNestRegExp188hi def link awkNestRegExp	Keyword189hi def link awkRegExp		Special190hi def link awkNumber		Number191hi def link awkFloat		Float192hi def link awkFileIO		Special193hi def link awkOperator		Special194hi def link awkExpression	Special195hi def link awkBoolLogic	Special196hi def link awkPatterns		Special197hi def link awkVariables	Special198hi def link awkFieldVars	Special199hi def link awkLineSkip		Special200hi def link awkSemicolon	Special201hi def link awkComma		Special202hi def link awkIdentifier	Identifier203hi def link awkComment		Comment204hi def link awkTodo		Todo205" Change this if you want nested array names to be highlighted.206hi def link awkArrayArray	awkArray207hi def link awkArrayElement	Special208hi def link awkParenError	awkError209hi def link awkInParen		awkError210hi def link awkError		Error211 212let b:current_syntax = "awk"213 214let &cpo = s:cpo_save215unlet s:cpo_save216 217" vim: ts=8218 
codekingpro/portable-devtools · Team Ai