annotate runtime/syntax/sed.vim @ 8973:887bded0d8ea v7.4.1772

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