Mercurial > vim
annotate runtime/syntax/sed.vim @ 10048:43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 30 23:26:57 2016 +0200
Updated runtime files. Remove version checks for Vim older than 6.0.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 30 Aug 2016 23:30:09 +0200 |
parents | aa6412cab544 |
children | 46763b01cd9a |
rev | line source |
---|---|
7 | 1 " Vim syntax file |
2 " Language: sed | |
3 " Maintainer: Haakon Riiser <hakonrk@fys.uio.no> | |
4 " URL: http://folk.uio.no/hakonrk/vim/syntax/sed.vim | |
2231
aa6412cab544
Various improvements to undo file code to make it more robust.
Bram Moolenaar <bram@vim.org>
parents:
602
diff
changeset
|
5 " Last Change: 2010 May 29 |
7 | 6 |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
7 " quit when a syntax file was already loaded |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
8 if exists("b:current_syntax") |
7 | 9 finish |
10 endif | |
11 | |
12 syn match sedError "\S" | |
13 | |
14 syn match sedWhitespace "\s\+" contained | |
15 syn match sedSemicolon ";" | |
16 syn match sedAddress "[[:digit:]$]" | |
17 syn match sedAddress "\d\+\~\d\+" | |
18 syn region sedAddress matchgroup=Special start="[{,;]\s*/\(\\/\)\="lc=1 skip="[^\\]\(\\\\\)*\\/" end="/I\=" contains=sedTab,sedRegexpMeta | |
19 syn region sedAddress matchgroup=Special start="^\s*/\(\\/\)\=" skip="[^\\]\(\\\\\)*\\/" end="/I\=" contains=sedTab,sedRegexpMeta | |
20 syn match sedComment "^\s*#.*$" | |
602 | 21 syn match sedFunction "[dDgGhHlnNpPqQx=]\s*\($\|;\)" contains=sedSemicolon,sedWhitespace |
7 | 22 syn match sedLabel ":[^;]*" |
23 syn match sedLineCont "^\(\\\\\)*\\$" contained | |
24 syn match sedLineCont "[^\\]\(\\\\\)*\\$"ms=e contained | |
25 syn match sedSpecial "[{},!]" | |
26 if exists("highlight_sedtabs") | |
27 syn match sedTab "\t" contained | |
28 endif | |
29 | |
30 " Append/Change/Insert | |
31 syn region sedACI matchgroup=sedFunction start="[aci]\\$" matchgroup=NONE end="^.*$" contains=sedLineCont,sedTab | |
32 | |
33 syn region sedBranch matchgroup=sedFunction start="[bt]" matchgroup=sedSemicolon end=";\|$" contains=sedWhitespace | |
34 syn region sedRW matchgroup=sedFunction start="[rw]" matchgroup=sedSemicolon end=";\|$" contains=sedWhitespace | |
35 | |
36 " Substitution/transform with various delimiters | |
37 syn region sedFlagwrite matchgroup=sedFlag start="w" matchgroup=sedSemicolon end=";\|$" contains=sedWhitespace contained | |
38 syn match sedFlag "[[:digit:]gpI]*w\=" contains=sedFlagwrite contained | |
39 syn match sedRegexpMeta "[.*^$]" contained | |
40 syn match sedRegexpMeta "\\." contains=sedTab contained | |
41 syn match sedRegexpMeta "\[.\{-}\]" contains=sedTab contained | |
42 syn match sedRegexpMeta "\\{\d\*,\d*\\}" contained | |
43 syn match sedRegexpMeta "\\(.\{-}\\)" contains=sedTab contained | |
44 syn match sedReplaceMeta "&\|\\\($\|.\)" contains=sedTab contained | |
45 | |
46 " Metacharacters: $ * . \ ^ [ ~ | |
47 " @ is used as delimiter and treated on its own below | |
48 let __at = char2nr("@") | |
2231
aa6412cab544
Various improvements to undo file code to make it more robust.
Bram Moolenaar <bram@vim.org>
parents:
602
diff
changeset
|
49 let __sed_i = char2nr(" ") " ASCII: 32, EBCDIC: 64 |
7 | 50 if has("ebcdic") |
51 let __sed_last = 255 | |
52 else | |
53 let __sed_last = 126 | |
54 endif | |
55 let __sed_metacharacters = '$*.\^[~' | |
56 while __sed_i <= __sed_last | |
57 let __sed_delimiter = escape(nr2char(__sed_i), __sed_metacharacters) | |
58 if __sed_i != __at | |
59 exe 'syn region sedAddress matchgroup=Special start=@\\'.__sed_delimiter.'\(\\'.__sed_delimiter.'\)\=@ skip=@[^\\]\(\\\\\)*\\'.__sed_delimiter.'@ end=@'.__sed_delimiter.'I\=@ contains=sedTab' | |
60 exe 'syn region sedRegexp'.__sed_i 'matchgroup=Special start=@'.__sed_delimiter.'\(\\\\\|\\'.__sed_delimiter.'\)*@ skip=@[^\\'.__sed_delimiter.']\(\\\\\)*\\'.__sed_delimiter.'@ end=@'.__sed_delimiter.'@me=e-1 contains=sedTab,sedRegexpMeta keepend contained nextgroup=sedReplacement'.__sed_i | |
61 exe 'syn region sedReplacement'.__sed_i 'matchgroup=Special start=@'.__sed_delimiter.'\(\\\\\|\\'.__sed_delimiter.'\)*@ skip=@[^\\'.__sed_delimiter.']\(\\\\\)*\\'.__sed_delimiter.'@ end=@'.__sed_delimiter.'@ contains=sedTab,sedReplaceMeta keepend contained nextgroup=sedFlag' | |
62 endif | |
63 let __sed_i = __sed_i + 1 | |
64 endwhile | |
65 syn region sedAddress matchgroup=Special start=+\\@\(\\@\)\=+ skip=+[^\\]\(\\\\\)*\\@+ end=+@I\=+ contains=sedTab,sedRegexpMeta | |
66 syn region sedRegexp64 matchgroup=Special start=+@\(\\\\\|\\@\)*+ skip=+[^\\@]\(\\\\\)*\\@+ end=+@+me=e-1 contains=sedTab,sedRegexpMeta keepend contained nextgroup=sedReplacement64 | |
67 syn region sedReplacement64 matchgroup=Special start=+@\(\\\\\|\\@\)*+ skip=+[^\\@]\(\\\\\)*\\@+ end=+@+ contains=sedTab,sedReplaceMeta keepend contained nextgroup=sedFlag | |
68 | |
69 " Since the syntax for the substituion command is very similar to the | |
70 " syntax for the transform command, I use the same pattern matching | |
71 " for both commands. There is one problem -- the transform command | |
72 " (y) does not allow any flags. To save memory, I ignore this problem. | |
73 syn match sedST "[sy]" nextgroup=sedRegexp\d\+ | |
74 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
75 command -nargs=+ HiLink hi def link <args> |
7 | 76 |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
77 HiLink sedAddress Macro |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
78 HiLink sedACI NONE |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
79 HiLink sedBranch Label |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
80 HiLink sedComment Comment |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
81 HiLink sedDelete Function |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
82 HiLink sedError Error |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
83 HiLink sedFlag Type |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
84 HiLink sedFlagwrite Constant |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
85 HiLink sedFunction Function |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
86 HiLink sedLabel Label |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
87 HiLink sedLineCont Special |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
88 HiLink sedPutHoldspc Function |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
89 HiLink sedReplaceMeta Special |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
90 HiLink sedRegexpMeta Special |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
91 HiLink sedRW Constant |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
92 HiLink sedSemicolon Special |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
93 HiLink sedST Function |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
94 HiLink sedSpecial Special |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
95 HiLink sedWhitespace NONE |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
96 if exists("highlight_sedtabs") |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
97 HiLink sedTab Todo |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
98 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
99 let __sed_i = char2nr(" ") " ASCII: 32, EBCDIC: 64 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
100 while __sed_i <= __sed_last |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
101 exe "HiLink sedRegexp".__sed_i "Macro" |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
102 exe "HiLink sedReplacement".__sed_i "NONE" |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
103 let __sed_i = __sed_i + 1 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
104 endwhile |
7 | 105 |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2231
diff
changeset
|
106 delcommand HiLink |
7 | 107 |
2231
aa6412cab544
Various improvements to undo file code to make it more robust.
Bram Moolenaar <bram@vim.org>
parents:
602
diff
changeset
|
108 unlet __sed_i __sed_last __sed_delimiter __sed_metacharacters |
7 | 109 |
110 let b:current_syntax = "sed" | |
111 | |
112 " vim: sts=4 sw=4 ts=8 |