" Vim syntax file " Language: ed(1) " Maintainer: Doug Kearns " Last Change: 2026 Jul 30 if exists("b:current_syntax") finish endif let s:cpo_save = &cpo set cpo&vim syn match edLineStart \ /^/ \ skipwhite \ nextgroup=@edAddress,edAddressSeparator,@edCommand " Addresses {{{1 " TODO: Rename edAddress_Line, edAdress_Mark etc? syn match edAddress contained \ /[.$]\|\d\+\|'[a-z]/ \ skipwhite \ nextgroup=@edAddressModifier,edAddressSeparator,@edCommand syn region edAddress_Pattern contained \ matchgroup=Delimiter \ start=+/+ \ end=+/\|$+ \ skipwhite \ nextgroup=@edAddressModifier, \ edAddressSeparator, \ @edCommand, \ edAddress_Pattern_Flag \ contains=edRegex_SlashEscape, \ edRegex_BackslashEscape, \ edRegex_BracketExpression syn region edAddress_Pattern contained \ matchgroup=Delimiter \ start=/?/ \ end=/?\|$/ \ skipwhite \ nextgroup=@edAddressModifier, \ edAddressSeparator, \ @edCommand, \ edAddress_Pattern_Flag \ contains=edRegex_QuestionMarkEscape, \ edRegex_BackslashEscape, \ edRegex_BracketExpression syn match edAddress_Pattern_Flag contained \ +[/?]\@1<=I+ \ skipwhite \ nextgroup=@edAddressModifier,edAddressSeparator,@edCommand syn match edRegex_BracketExpression contained \ "\[\^\=\]\=\%(\[:.\{-}:\]\|\[\..\{-}\.\]\|\[=.\{-}=\]\|[^]]\)*\]" \ contains=NONE \ transparent syn match edRegex_SlashEscape contained \ +\\/+ \ contains=NONE \ transparent syn match edRegex_QuestionMarkEscape contained \ /\\?/ \ contains=NONE \ transparent syn match edRegex_BackslashEscape contained \ /\\\\/ \ contains=NONE \ transparent syn match edRegex_EscapeSequence contained \ /\\./ \ contains=NONE \ transparent syn cluster edAddress \ contains=edAddress,edAddress_Pattern,edAddressModifier_Offset syn match edAddressModifier_Offset contained \ /[+-]\s*\%(\d\+\)\=/ \ skipwhite \ nextgroup=@edAddressModifier,edAddressSeparator,@edCommand " BSD extension syn match edAddressModifier_Offset contained \ /\^\s*\%(\d\+\)\=/ \ skipwhite \ nextgroup=@edAddressModifier,edAddressSeparator,@edCommand syn match edAddressModifier_Count contained \ /\d\+/ \ skipwhite \ nextgroup=@edAddressModifier,edAddressSeparator,@edCommand syn cluster edAddressModifier \ contains=edAddressModifier_Offset,edAddressModifier_Count syn match edAddressSeparator contained \ /[,;]/ \ skipwhite \ nextgroup=@edAddress,edAddressSeparator,@edCommand " BSD/GNU extension syn match edAddressSeparator contained \ /%/ \ skipwhite \ nextgroup=@edAddress,edAddressSeparator,@edCommand " Commands {{{1 " Append Command {{{2 syn match edCommand_Append contained \ /a/ \ skipnl \ nextgroup=@edCommandPrint_InputMode, \ edArg_InputMode_Text, \ edArg_InputMode_EndMarker, \ edLineContinue_InputMode syn match edArg_InputMode_EndMarker contained \ /^\.\ze\%(\s*\\\)\=$/ syn region edArg_InputMode_Text contained \ start=/^\%(\.$\)\@!/ "\ end=/^\.$/ \ matchgroup=edArg_InputMode_EndMarker "\ TODO: remove \\? \ end=/^\.\ze\%(\s*\\\)\=$/ \ fold syn region edArg_InputMode_Text_Global contained \ start=/^\%(\.$\)\@!/ \ end=/\ze\\\@1/ \ skipwhite \ nextgroup=edArg_File,edCommand_ShellEscape " Substitute Command {{{2 syn match edCommand_Substitute contained \ /s/ \ nextgroup=edCommand_Substitute_Arg_Regexp syn region edCommand_Substitute_Arg_Regexp contained \ matchgroup=Delimiter \ start=/\z([^\\ \n]\)/ "\ /$/ so we don't run to EOF when editing \ end=/\ze\z1\|$/ \ nextgroup=edCommand_Substitute_Arg_Replacement \ contains=edRegex_EscapeSequence,edRegex_BracketExpression syn region edCommand_Substitute_Arg_Replacement contained \ matchgroup=Delimiter \ start=/\z(.\)/ \ skip=/\\$/ \ end=/\z1\|$/ \ nextgroup=edCommand_Substitute_Arg_Flag,edCommand_Substitute_Arg_Count \ contains=edCommand_Substitute_Arg_Replacement_Escape, \ edCommand_Substitute_Arg_Replacement_Newline, \ edCommand_Substitute_Arg_Replacement_Match syn region edCommand_Substitute_Arg_Replacement contained \ matchgroup=Delimiter \ start=/\z(.\)%\@=/ \ end=/\%(\z1%\)\@<=\%(\z1\|$\)/ \ nextgroup=edCommand_Substitute_Arg_Flag,edCommand_Substitute_Arg_Count \ contains=edCommand_Substitute_Arg_Replacement_Repeat \ oneline syn match edCommand_Substitute_Arg_Replacement_Escape contained /\\./ syn match edCommand_Substitute_Arg_Replacement_Newline contained /\\$/ syn match edCommand_Substitute_Arg_Replacement_Match contained /&/ syn match edCommand_Substitute_Arg_Replacement_Repeat contained /%/ syn match edCommand_Substitute_Arg_Flag contained \ /g/ \ nextgroup=edCommand_Substitute_Arg_Flag,edCommand_Substitute_Arg_Count " GNU extension syn match edCommand_Substitute_Arg_Flag contained \ /[iI]/ \ nextgroup=edCommand_Substitute_Arg_Flag,edCommand_Substitute_Arg_Count syn match edCommand_Substitute_Arg_Count contained \ /\d\+/ \ nextgroup=edCommand_Substitute_Arg_Flag syn match edCommand_Substitute_Arg_Flag contained \ /[lnp]/ \ skipnl \ nextgroup=edCommand_Substitute_Arg_Flag,edCommand_Substitute_Arg_Count " repeat last s command " BSD/GNU extension syn match edCommand_Substitute contained \ /s\%(\%([gpr]\|\d\+\)\{1,4}\&\%(.*\([gpr]\).*\1\)\@!\&\%(.*\d\D\+\d\)\@!.*\)\>/ \ contains=edCommand_Substitute_Arg_Flag,edCommand_Substitute_Arg_Count syn match edCommand_Substitute_Arg_Flag contained \ /r/ \ nextgroup=edCommand_Substitute_Arg_Flag,edCommand_Substitute_Arg_Count " Copy Command {{{2 syn match edCommand_Copy contained \ /t/ "\ GNU extension \ skipwhite \ nextgroup=@edAddress,edAddressSeparator,@edCommandPrint " TODO: maybe implement as a region so that the command list is contained? " Global Not-Matched Command {{{2 syn match edCommand_GlobalNotMatched contained \ /v/ \ nextgroup=edCommand_GlobalNotMatched_Arg_Regexp syn region edCommand_GlobalNotMatched_Arg_Regexp contained \ matchgroup=Delimiter \ start=/\z([^\\ \n]\)/ \ end=/\z1\|$/ \ skipwhite \ nextgroup=@edAddress, \ edAddressSeparator, \ @edCommand, \ edCommand_GlobalNotMatched_Arg_Regexp_Flag \ contains=edRegex_EscapeSequence,edRegex_BracketExpression " GNU extension syn match edCommand_GlobalNotMatched_Arg_Regexp_Flag contained \ /[^\\ \n]\@1<=I/ \ skipwhite \ nextgroup=@edAddress,edAddressSeparator,@edCommand " Interactive Global Not-Matched Command {{{2 syn match edCommand_InteractiveGlobalNotMatched contained \ /V/ \ nextgroup=edCommand_InteractiveGlobalNotMatched_Arg_Regexp syn region edCommand_InteractiveGlobalNotMatched_Arg_Regexp contained \ matchgroup=Delimiter \ start=/\z([^\\ \n]\)/ \ end=/\z1\|$/ \ nextgroup=edCommand_InteractiveGlobalNotMatched_Arg_Regexp_Flag \ contains=edRegex_EscapeSequence,edRegex_BracketExpression " GNU extension syn match edCommand_InteractiveGlobalNotMatched_Arg_Regexp_Flag contained \ /[^\\ \n]\@1<=I/ " Write Command {{{2 syn match edCommand_Write contained \ /w\>/ \ skipwhite \ nextgroup=edArg_File,edCommand_ShellEscape " Write Append Command {{{2 " BSD/GNU extension syn match edCommand_WriteAppend contained \ /W\>/ \ skipwhite \ nextgroup=edArg_File,edCommand_ShellEscape " Write Quit Command {{{2 " BSD/GNU extension syn match edCommand_WriteQuit contained \ /wq\>/ \ skipwhite \ nextgroup=edArg_File,edCommand_ShellEscape " Paste Cut Buffer Command {{{2 " GNU extension syn match edCommand_Paste contained \ /x/ \ nextgroup=@edCommandPrint " Yank Cut Buffer Command {{{2 " GNU extension syn match edCommand_Yank contained \ /y/ \ nextgroup=@edCommandPrint " Scroll Command {{{2 " BSD/GNU extension syn match edCommand_Scroll contained \ /z/ \ nextgroup=edCommand_Scroll_Arg_Count,@edCommandPrint syn match edCommand_Scroll_Arg_Count contained \ /\d\+/ \ nextgroup=@edCommandPrint " Line Number Command {{{2 syn match edCommand_LineNumber contained \ /=/ \ nextgroup=@edCommandPrint " }}} " no address prefix commands " Edit Command {{{2 syn match edCommand_Edit contained \ /\/ \ skipwhite \ nextgroup=edArg_File,edCommand_ShellEscape " Edit Without Checking Command {{{2 syn match edCommand_EditWithoutChecking contained \ /\/ \ skipwhite \ nextgroup=edArg_File,edCommand_ShellEscape " Filename Command {{{2 syn match edCommand_Filename contained \ /\/ \ skipwhite \ nextgroup=edArg_File " Help Command {{{2 syn match edCommand_Help contained \ /\/ " Quit Without Checking Command {{{2 syn match edCommand_QuitWithoutChecking contained \ /\/ " Undo Command {{{2 syn match edCommand_Undo contained \ /\