robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1" Vim syntax file 2" Language: ed(1) 3" Maintainer: Doug Kearns <dougkearns@gmail.com> 4" Last Change: 2026 Aug 27 5 6if exists ( "b:current_syntax" ) 7finish 8endif 9let s: cpo_save = & cpo 10set cpo & vim 11 12syn match edLineStart 13 \ /^ / 14 \skipwhite 15 \nextgroup = @edAddress , edAddressSeparator , @edCommand 16 17" Addresses {{{1 18 19" TODO: Rename edAddress_Line, edAdress_Mark etc? 20syn match edAddress contained 21 \ /[ .$ ] \|\d\+\|' [ a-z ] / 22 \skipwhite 23 \nextgroup = @edAddressModifier , edAddressSeparator , @edCommand 24syn region edAddress_Pattern contained 25 \matchgroup = Delimiter 26 \start = +/ + 27 \end = +/\|$ + 28 \skipwhite 29 \nextgroup = @edAddressModifier , 30 \edAddressSeparator , 31 \@edCommand , 32 \edAddress_Pattern_Flag 33 \contains = edRegex_SlashEscape , 34 \edRegex_BackslashEscape , 35 \edRegex_BracketExpression 36syn region edAddress_Pattern contained 37 \matchgroup = Delimiter 38 \start = /? / 39 \end = /?\|$ / 40 \skipwhite 41 \nextgroup = @edAddressModifier , 42 \edAddressSeparator , 43 \@edCommand , 44 \edAddress_Pattern_Flag 45 \contains = edRegex_QuestionMarkEscape , 46 \edRegex_BackslashEscape , 47 \edRegex_BracketExpression 48 49syn match edAddress_Pattern_Flag contained 50 \ +[ /? ] \@1<=I + 51 \skipwhite 52 \nextgroup = @edAddressModifier , edAddressSeparator , @edCommand 53 54syn match edRegex_BracketExpression contained 55 \ /\[\^\=\]\=\%(\[:.\{-}:\]\|\[\..\{-}\.\]\|\[=.\{-}=\]\| [ ^ ] ]\) * \] / 56 \contains = NONE 57 \transparent 58syn match edRegex_SlashEscape contained 59 \ +\\/ + 60 \contains = NONE 61 \transparent 62syn match edRegex_QuestionMarkEscape contained 63 \ /\\? / 64 \contains = NONE 65 \transparent 66syn match edRegex_BackslashEscape contained 67 \ /\\\\ / 68 \contains = NONE 69 \transparent 70syn match edRegex_EscapeSequence contained 71 \ /\\. / 72 \contains = NONE 73 \transparent 74 75 76syn cluster edAddress 77 \contains = edAddress , edAddress_Pattern , edAddressModifier_Offset 78 79syn match edAddressModifier_Offset contained 80 \ /[ +- ] \s * \%(\d\+\)\= / 81 \skipwhite 82 \nextgroup = @edAddressModifier , edAddressSeparator , @edCommand 83" BSD extension 84syn match edAddressModifier_Offset contained 85 \ /\^\s * \%(\d\+\)\= / 86 \skipwhite 87 \nextgroup = @edAddressModifier , edAddressSeparator , @edCommand 88syn match edAddressModifier_Count contained 89 \ /\d\+ / 90 \skipwhite 91 \nextgroup = @edAddressModifier , edAddressSeparator , @edCommand 92syn cluster edAddressModifier 93 \contains = edAddressModifier_Offset , edAddressModifier_Count 94 95syn match edAddressSeparator contained 96 \ /[ ,; ] / 97 \skipwhite 98 \nextgroup = @edAddress , edAddressSeparator , @edCommand 99" BSD/GNU extension 100syn match edAddressSeparator contained 101 \ /% / 102 \skipwhite 103 \nextgroup = @edAddress , edAddressSeparator , @edCommand 104 105" Commands {{{1 106 107" Append Command {{{2 108syn match edCommand_Append contained 109 \ /a / 110 \skipnl 111 \nextgroup = @edCommandPrint_InputMode , 112 \edArg_InputMode_Text , 113 \edArg_InputMode_EndMarker , 114 \edLineContinue_InputMode 115 116syn match edArg_InputMode_EndMarker contained 117 \ /^\.\ze\%(\s * \\\)\=$ / 118 119syn region edArg_InputMode_Text contained 120 \start = /^\%(\.$\)\@! / 121"\ end=/^\.$/ 122 \matchgroup = edArg_InputMode_EndMarker 123"\ TODO: remove \\? 124 \end = /^\.\ze\%(\s * \\\)\=$ / 125 \fold 126syn region edArg_InputMode_Text_Global contained 127 \start = /^\%(\.$\)\@! / 128 \end = /\ze\\\@1<!\n / 129 \matchgroup = edArg_InputMode_EndMarker 130 \end = /^\.\ze\%(\s * \\\)\=$ / 131 \skipwhite 132 \nextgroup = edLineContinue 133 \contains = edLineContinue_InputMode_Text 134 \fold 135 136" Change Command {{{2 137syn match edCommand_Change contained 138 \ /c / 139 \skipnl 140 \nextgroup = @edCommandPrint_InputMode , 141 \edArg_InputMode_Text , 142 \edArg_InputMode_EndMarker , 143 \edLineContinue_InputMode 144 145" Delete Command {{{2 146syn match edCommand_Delete contained 147 \ /d / 148 \nextgroup = @edCommandPrint 149 150" TODO: maybe implement as a region so that the command list is contained? 151" Global Command {{{2 152syn match edCommand_Global contained 153 \ /g / 154 \nextgroup = edCommand_Global_Arg_Regexp 155syn region edCommand_Global_Arg_Regexp contained 156 \matchgroup = Delimiter 157 \start = /\z( [ ^\\ \n ] \) / 158 \end = /\z1\|$ / 159 \skipwhite 160 \nextgroup = @edAddress , 161 \edAddressSeparator , 162 \@edCommand , 163 \edCommand_Global_Arg_Regexp_Flag 164 \contains = edRegex_EscapeSequence , edRegex_BracketExpression 165 166" GNU extension 167syn match edCommand_Global_Arg_Regexp_Flag contained 168 \ /[ ^\\ \n ] \@1<=I / 169 \skipwhite 170 \nextgroup = @edAddress , edAddressSeparator , @edCommand 171 172syn match edLineContinue_InputMode contained 173 \ /\\$ / 174 \skipnl 175 \nextgroup = edArg_InputMode_Text_Global , edArg_InputMode_EndMarker 176syn match edLineContinue_InputMode_Text contained /\\$ / 177syn match edLineContinue /\\$ /skipnl nextgroup = edLineStart 178 179" Interactive Global Command {{{2 180syn match edCommand_InteractiveGlobal contained 181 \ /G / 182 \nextgroup = edCommand_InteractiveGlobal_Arg_Regexp 183syn region edCommand_InteractiveGlobal_Arg_Regexp contained 184 \matchgroup = Delimiter 185 \start = /\z( [ ^\\ \n ] \) / 186 \end = /\z1\|$ / 187 \nextgroup = edCommand_InteractiveGlobal_Arg_Regexp_Flag 188 \contains = edRegex_EscapeSequence , edRegex_BracketExpression 189 190" GNU extension 191syn match edCommand_InteractiveGlobal_Arg_Regexp_Flag contained 192 \ /[ ^\\ \n ] \@1<=I / 193 194syn match edCommand_Repeat contained 195 \ /& / 196 197" Insert Command {{{2 198syn match edCommand_Insert contained 199 \ /i / 200 \skipnl 201 \nextgroup = @edCommandPrint_InputMode , 202 \edArg_InputMode_Text , 203 \edArg_InputMode_EndMarker , 204 \edLineContinue_InputMode 205 206" Join Command {{{2 207syn match edCommand_Join contained 208 \ /j / 209 \nextgroup = @edCommandPrint 210 211" Mark Command {{{2 212syn match edCommand_Mark contained 213 \ /k / 214 \nextgroup = edCommand_Mark_Arg_Name 215syn match edCommand_Mark_Arg_Name contained 216 \ /[ a-z ] / 217 \nextgroup = @edCommandPrint 218 219" List Command {{{2 220syn match edCommand_List contained 221 \ /l / 222 \nextgroup = @edCommandPrint 223 224syn match edCommand_List_InputMode contained 225 \ /^\@1<!l / 226 \skipnl 227 \nextgroup = @edCommandPrint_InputMode , 228 \edArg_InputMode_Text , 229 \edArg_InputMode_EndMarker , 230 \edLineContinue_InputMode 231 232" Move Command {{{2 233syn match edCommand_Move contained 234 \ /m / 235"\ GNU extension 236 \skipwhite 237 \nextgroup = @edAddress , edAddressSeparator , @edCommandPrint 238 239" Number Command {{{2 240syn match edCommand_Number contained 241 \ /n / 242 \nextgroup = @edCommandPrint 243 244syn match edCommand_Number_InputMode contained 245 \ /^\@1<!n / 246 \skipnl 247 \nextgroup = @edCommandPrint_InputMode , 248 \edArg_InputMode_Text , 249 \edArg_InputMode_EndMarker , 250 \edLineContinue_InputMode 251 252" Print Command {{{2 253syn match edCommand_Print contained 254 \ /p / 255 \nextgroup = @edCommandPrint 256 257syn match edCommand_Print_InputMode contained 258 \ /^\@1<!p / 259 \skipnl 260 \nextgroup = @edCommandPrint_InputMode , 261 \edArg_InputMode_Text , 262 \edArg_InputMode_EndMarker , 263 \edLineContinue_InputMode 264 265" Read Command {{{2 266syn match edCommand_Read contained 267 \ /r\> / 268 \skipwhite 269 \nextgroup = edArg_File , edCommand_ShellEscape 270 271" Substitute Command {{{2 272syn match edCommand_Substitute contained 273 \ /s / 274 \nextgroup = edCommand_Substitute_Arg_Regexp 275syn region edCommand_Substitute_Arg_Regexp contained 276 \matchgroup = Delimiter 277 \start = /\z( [ ^\\ \n ] \) / 278"\ /$/ so we don't run to EOF when editing 279 \end = /\ze\z1\|$ / 280 \nextgroup = edCommand_Substitute_Arg_Replacement 281 \contains = edRegex_EscapeSequence , edRegex_BracketExpression 282syn region edCommand_Substitute_Arg_Replacement contained 283 \matchgroup = Delimiter 284 \start = /\z(.\) / 285 \skip = /\\$ / 286 \end = /\z1\|$ / 287 \nextgroup = edCommand_Substitute_Arg_Flag , edCommand_Substitute_Arg_Count 288 \contains = edCommand_Substitute_Arg_Replacement_Escape , 289 \edCommand_Substitute_Arg_Replacement_Newline , 290 \edCommand_Substitute_Arg_Replacement_Match 291 292syn region edCommand_Substitute_Arg_Replacement contained 293 \matchgroup = Delimiter 294 \start = /\z(.\)%\@= / 295 \end = /\%(\z1%\)\@<=\%(\z1\|$\) / 296 \nextgroup = edCommand_Substitute_Arg_Flag , edCommand_Substitute_Arg_Count 297 \contains = edCommand_Substitute_Arg_Replacement_Repeat 298 \oneline 299 300syn match edCommand_Substitute_Arg_Replacement_Escape contained /\\. / 301syn match edCommand_Substitute_Arg_Replacement_Newline contained /\\$ / 302syn match edCommand_Substitute_Arg_Replacement_Match contained /& / 303syn match edCommand_Substitute_Arg_Replacement_Repeat contained /% / 304 305syn match edCommand_Substitute_Arg_Flag contained 306 \ /g / 307 \nextgroup = edCommand_Substitute_Arg_Flag , edCommand_Substitute_Arg_Count 308" GNU extension 309syn match edCommand_Substitute_Arg_Flag contained 310 \ /[ iI ] / 311 \nextgroup = edCommand_Substitute_Arg_Flag , edCommand_Substitute_Arg_Count 312 313syn match edCommand_Substitute_Arg_Count contained 314 \ /\d\+ / 315 \nextgroup = edCommand_Substitute_Arg_Flag 316 317syn match edCommand_Substitute_Arg_Flag contained 318 \ /[ lnp ] / 319 \skipnl 320 \nextgroup = edCommand_Substitute_Arg_Flag , edCommand_Substitute_Arg_Count 321 322" repeat last s command 323" BSD/GNU extension 324 325syn match edCommand_Substitute contained 326 \ /s\%(\%( [ gpr ] \|\d\+\)\{1,4}\&\%(. * \( [ gpr ] \). * \1\)\@!\&\%(. * \d\D\+\d\)\@!. * \)\> / 327 \contains = edCommand_Substitute_Arg_Flag , edCommand_Substitute_Arg_Count 328 329syn match edCommand_Substitute_Arg_Flag contained 330 \ /r / 331 \nextgroup = edCommand_Substitute_Arg_Flag , edCommand_Substitute_Arg_Count 332 333" Copy Command {{{2 334syn match edCommand_Copy contained 335 \ /t / 336"\ GNU extension 337 \skipwhite 338 \nextgroup = @edAddress , edAddressSeparator , @edCommandPrint 339 340" TODO: maybe implement as a region so that the command list is contained? 341" Global Not-Matched Command {{{2 342syn match edCommand_GlobalNotMatched contained 343 \ /v / 344 \nextgroup = edCommand_GlobalNotMatched_Arg_Regexp 345syn region edCommand_GlobalNotMatched_Arg_Regexp contained 346 \matchgroup = Delimiter 347 \start = /\z( [ ^\\ \n ] \) / 348 \end = /\z1\|$ / 349 \skipwhite 350 \nextgroup = @edAddress , 351 \edAddressSeparator , 352 \@edCommand , 353 \edCommand_GlobalNotMatched_Arg_Regexp_Flag 354 \contains = edRegex_EscapeSequence , edRegex_BracketExpression 355 356" GNU extension 357syn match edCommand_GlobalNotMatched_Arg_Regexp_Flag contained 358 \ /[ ^\\ \n ] \@1<=I / 359 \skipwhite 360 \nextgroup = @edAddress , edAddressSeparator , @edCommand 361 362" Interactive Global Not-Matched Command {{{2 363syn match edCommand_InteractiveGlobalNotMatched contained 364 \ /V / 365 \nextgroup = edCommand_InteractiveGlobalNotMatched_Arg_Regexp 366syn region edCommand_InteractiveGlobalNotMatched_Arg_Regexp contained 367 \matchgroup = Delimiter 368 \start = /\z( [ ^\\ \n ] \) / 369 \end = /\z1\|$ / 370 \nextgroup = edCommand_InteractiveGlobalNotMatched_Arg_Regexp_Flag 371 \contains = edRegex_EscapeSequence , edRegex_BracketExpression 372 373" GNU extension 374syn match edCommand_InteractiveGlobalNotMatched_Arg_Regexp_Flag contained 375 \ /[ ^\\ \n ] \@1<=I / 376 377" Write Command {{{2 378syn match edCommand_Write contained 379 \ /w\> / 380 \skipwhite 381 \nextgroup = edArg_File , edCommand_ShellEscape 382 383" Write Append Command {{{2 384" BSD/GNU extension 385syn match edCommand_WriteAppend contained 386 \ /W\> / 387 \skipwhite 388 \nextgroup = edArg_File , edCommand_ShellEscape 389 390" Write Quit Command {{{2 391" BSD/GNU extension 392syn match edCommand_WriteQuit contained 393 \ /wq\> / 394 \skipwhite 395 \nextgroup = edArg_File , edCommand_ShellEscape 396 397" Paste Cut Buffer Command {{{2 398" GNU extension 399syn match edCommand_Paste contained 400 \ /x / 401 \nextgroup = @edCommandPrint 402 403" Yank Cut Buffer Command {{{2 404" GNU extension 405syn match edCommand_Yank contained 406 \ /y / 407 \nextgroup = @edCommandPrint 408 409" Scroll Command {{{2 410" BSD/GNU extension 411syn match edCommand_Scroll contained 412 \ /z / 413 \nextgroup = edCommand_Scroll_Arg_Count , @edCommandPrint 414syn match edCommand_Scroll_Arg_Count contained 415 \ /\d\+ / 416 \nextgroup = @edCommandPrint 417 418" Line Number Command {{{2 419syn match edCommand_LineNumber contained 420 \ /= / 421 \nextgroup = @edCommandPrint 422" }}} 423 424" no address prefix commands 425 426" Edit Command {{{2 427syn match edCommand_Edit contained 428 \ /\<e\> / 429 \skipwhite 430 \nextgroup = edArg_File , edCommand_ShellEscape 431 432" Edit Without Checking Command {{{2 433syn match edCommand_EditWithoutChecking contained 434 \ /\<E\> / 435 \skipwhite 436 \nextgroup = edArg_File , edCommand_ShellEscape 437 438" Filename Command {{{2 439syn match edCommand_Filename contained 440 \ /\<f\> / 441 \skipwhite 442 \nextgroup = edArg_File 443 444" Help Command {{{2 445syn match edCommand_Help contained 446 \ /\<h / 447 \nextgroup = @edCommandPrint 448 449" Help-Mode Command {{{2 450syn match edCommand_HelpMode contained 451 \ /\<H / 452 \nextgroup = @edCommandPrint 453 454" Prompt Command {{{2 455syn match edCommand_Prompt contained 456 \ /\<P / 457 \nextgroup = @edCommandPrint 458 459" Quit Command {{{2 460syn match edCommand_Quit contained 461 \ /\<q\> / 462 463" Quit Without Checking Command {{{2 464syn match edCommand_QuitWithoutChecking contained 465 \ /\<Q\> / 466 467" Undo Command {{{2 468syn match edCommand_Undo contained 469 \ /\<u / 470 \nextgroup = @edCommandPrint 471 472" Shell Escape Command {{{2 473syn match edCommand_ShellEscape contained 474 \ /! / 475 \skipwhite 476 \nextgroup = edCommand_ShellEscape_Arg_Command , 477 \edCommand_ShellEscape_Arg_Previous 478syn match edCommand_ShellEscape_Arg_Command contained 479 \ /\S. * $ / 480 \contains = edCommand_ShellEscape_Arg_Command_Filename , 481 \edCommand_ShellEscape_Arg_Command_FilenameEscape , 482 \edCommand_ShellEscape_Arg_Command_BackslashEscape 483 484syn match edCommand_ShellEscape_Arg_Command_Filename contained 485 \ /% / 486 487syn match edCommand_ShellEscape_Arg_Command_FilenameEscape contained /\\% / 488syn match edCommand_ShellEscape_Arg_Command_BackslashEscape contained /\\\\ / 489 490syn match edCommand_ShellEscape_Arg_Previous contained 491 \ /! / 492 \skipwhite 493 \nextgroup = edCommand_ShellEscape_Arg_Command 494 495" Comment Command {{{2 496" GNU extension 497syn match edCommand_Comment contained 498 \ /#. * / 499" }}} 500 501syn cluster edCommand contains = edCommand_ \a\+ 502 503" Command Args {{{2 504syn match edArg_File contained /!\@!\S. * $ / 505 506" Command Suffixes {{{1 507syn cluster edCommandPrint 508 \contains = edCommand_List , edCommand_Number , edCommand_Print 509syn cluster edCommandPrint_InputMode 510 \contains = edCommand_List_InputMode , 511 \edCommand_Number_InputMode , 512 \edCommand_Print_InputMode 513 514" Syncing {{{1 515 516syn sync fromstart 517 518" Default Highlighting {{{1 519 520" addresses 521 522hi def link edAddress Constant 523hi def link edAddressModifier_Offset Special 524hi def link edAddressModifier_Count Special 525hi def link edAddress_Pattern Regexp 526hi def link edAddress_Pattern_Flag Special 527 528" commands (addresses) 529 530hi def link edCommand Statement 531 532hi def link edCommand_Append Statement 533hi def link edCommand_Change Statement 534hi def link edCommand_Copy Statement 535hi def link edCommand_Delete Statement 536hi def link edCommand_GlobalNotMatched Statement 537hi def link edCommand_Global Statement 538hi def link edCommand_Insert Statement 539hi def link edCommand_InteractiveGlobalNotMatched Statement 540hi def link edCommand_InteractiveGlobal Statement 541hi def link edCommand_Join Statement 542hi def link edCommand_LineNumber Statement 543hi def link edCommand_List Statement 544hi def link edCommand_List_InputMode edCommand_List 545hi def link edCommand_Mark Statement 546hi def link edCommand_Move Statement 547hi def link edCommand_Number Statement 548hi def link edCommand_Number_InputMode edCommand_Number 549hi def link edCommand_Paste Statement 550hi def link edCommand_Print Statement 551hi def link edCommand_Print_InputMode edCommand_Print 552hi def link edCommand_Read Statement 553hi def link edCommand_Repeat Statement 554hi def link edCommand_Scroll Statement 555hi def link edCommand_Substitute Statement 556hi def link edCommand_WriteAppend Statement 557hi def link edCommand_WriteQuit Statement 558hi def link edCommand_Write Statement 559hi def link edCommand_Yank Statement 560 561" commands (no addresses) 562 563hi def link edCommand_Edit Statement 564hi def link edCommand_EditWithoutChecking Statement 565hi def link edCommand_Filename Statement 566hi def link edCommand_HelpMode Statement 567hi def link edCommand_Help Statement 568hi def link edCommand_Prompt Statement 569hi def link edCommand_Quit Statement 570hi def link edCommand_QuitWithoutChecking Statement 571hi def link edCommand_ShellEscape Statement 572hi def link edCommand_Undo Statement 573 574hi def link edCommand_Comment Comment 575 576" command args 577 578hi def link edArg_InputMode_Text Normal 579hi def link edArg_InputMode_Text_Global edArg_InputMode_Text 580hi def link edArg_InputMode_EndMarker edCommand 581 582hi def link edCommand_Mark_Arg_Name Constant 583 584hi def link edCommand_Scroll_Arg_Count Number 585 586hi def link edCommand_ShellEscape_Arg_Command_Filename Special 587hi def link edCommand_ShellEscape_Arg_Command_FilenameEscape Special 588hi def link edCommand_ShellEscape_Arg_Command_BackslashEscape Special 589hi def link edCommand_ShellEscape_Arg_Previous Constant 590 591hi def link edCommand_Substitute_Arg_Regexp Regexp 592hi def link edCommand_Substitute_Arg_Replacement_Escape Special 593hi def link edCommand_Substitute_Arg_Replacement_Newline Special 594hi def link edCommand_Substitute_Arg_Replacement_Match Special 595hi def link edCommand_Substitute_Arg_Replacement_Repeat Special 596hi def link edCommand_Substitute_Arg_Flag Special 597hi def link edCommand_Substitute_Arg_Count Special 598 599hi def link edCommand_Global_Arg_Regexp Regexp 600hi def link edCommand_Global_Arg_Regexp_Flag Special 601hi def link edCommand_InteractiveGlobal_Arg_Regexp Regexp 602hi def link edCommand_InteractiveGlobal_Arg_Regexp_Flag Special 603hi def link edCommand_GlobalNotMatched_Arg_Regexp Regexp 604hi def link edCommand_GlobalNotMatched_Arg_Regexp_Flag Special 605hi def link edCommand_InteractiveGlobalNotMatched_Arg_Regexp Regexp 606hi def link edCommand_InteractiveGlobalNotMatched_Arg_Regexp_Flag Special 607 608" line continuation 609 610hi def link edLineContinue Delimiter 611hi def link edLineContinue_InputMode edLineContinue 612hi def link edLineContinue_InputMode_Text edLineContinue 613 614 615" }}} 616 617let b: current_syntax = "ed" 618 619let & cpo = s: cpo_save 620unlet ! s: cpo_save 621 622" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: