Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Syntax Vim语法:仅在区域的开始处匹配-不匹配后续区域_Syntax_Vim - Fatal编程技术网

Syntax Vim语法:仅在区域的开始处匹配-不匹配后续区域

Syntax Vim语法:仅在区域的开始处匹配-不匹配后续区域,syntax,vim,Syntax,Vim,我有以下Vim语法文件: " Vim syntax file " Language: ScreenplayText - the textual source of ScreenplayXML " Maintainer: Shlomi Fish <shlomif@iglu.org.il> " Home: http://search.cpan.org/dist/XML-Grammar-Screenplay/ " " Author: Shlomi Fish " Filenames: *.s

我有以下Vim语法文件:

" Vim syntax file
" Language: ScreenplayText - the textual source of ScreenplayXML
" Maintainer: Shlomi Fish <shlomif@iglu.org.il>
" Home: http://search.cpan.org/dist/XML-Grammar-Screenplay/
"
" Author: Shlomi Fish
" Filenames: *.screenplay-text.txt
" Last Change: Thu Jul  3 00:59:42 IDT 2008
" Version: 0.0.1

" Thanks to Andy Wokula for his help on:
" https://groups.google.com/group/vim_use/browse_thread/thread/6c0906617d67864e/a21938c5df1d15cb?show_docid=a21938c5df1d15cb

" Quit if syntax file is already loaded
if version < 600
    syntax clear
elseif exists("b:current_syntax")
    finish
endif

syntax sync minlines=50

" syntax match screenplayTextComment /<!--\_.\{-0,}-->/
" syntax match screenplayTextDescription /^ *\[\_.\{-0,}\]/
syntax region screenplayTextComment start="<!--" end="-->"
syntax region screenplayTextDescription start="^ *\[" end="]"

" syntax region screenplayTextSaying start=/\(^\s*\n\)\@<=\_^\(+\{2,\}\|[^[:+]*\):/ end=/^\s*$/ contains=screenplayTextAddress,screenplayTextInnerDesc
syntax region screenplayTextSaying start=/\(^\s*\n\)\@<=\_^\(+\{2,\}\|[^[:+]*\):/ end=/^\s*$/ contains=screenplayTextAddress

" syntax match screenplayTextAddress /\%^\(+\{2,\}\|[^[:+]*\):/ contained nextgroup=screenplayTextInnerDesc
syntax match screenplayTextAddress /[^:]\+:/ contained nextgroup=screenplayTextSayingAfterAddress

syntax region screenplayTextSayingAfterAddress contained
" syntax match screenplayTextInnerDesc /\[\_.\{-0,}\]/ contained nextgroup=screenplayTextInnerDesc


" For debugging - remove.
" hi def link screenplayTextSaying Statement

hi def link screenplayTextComment Comment
hi def link screenplayTextDescription PreProc
hi def link screenplayTextInnerDesc PreProc
hi def screenplayTextAddress      term=bold cterm=bold gui=bold
带有“:”冒号的第二行仍然高亮显示。如何防止其突出显示

谢谢你的见解

问候,

--什洛米鱼


注意:这里是(bitbucket上的一个Mercurial)和这里是(在其GitHub git存储库中)。

识别段落第一行的唯一方法似乎是在一个空行之后

" Define blank line at first
syntax match EmptyLines "\(^\s*\n\)\+" nextgroup=FistLine, Description

" Then define Fist line
syntax region FirstLine start=+^[^\<\[]+ oneline contains=Address

" Then define Address
syntax match Address "^[^<\[]+:" contained

" Description
syntax match Description "\[[^\[]+\]"

" Comment
" Comment match code

" For the rest of text, just give them a general format
“首先定义空行
语法匹配空列表“\(^\s*\n\)\+”下一个组=第一行,说明
然后定义第一行

syntax region FirstLine start=+^[^\屏幕播放文本saying
组包含两个分支;我将它们分成两个单独的区域,然后使用
匹配组
直接在以冒号结尾的地址的区域开始处高亮显示。请参见
:help:syn matchgroup

syntax region screenplayTextSaying start=/\(^\s*\n\)\@<=\_^+\{2,\}:/ end=/^\s*$/
syntax region screenplayTextSaying end=/^\s*$/ matchgroup=screenplayTextAddress start=/\(^\s*\n\)\@<=\_^[^[:+]*:/
"syntax match screenplayTextAddress /[^:]\+:/ Not needed any more!

syntax region screenplayTextSaying start=/\(^\s*\n\)\@嗨,我说的不是分号-«;»,而是冒号-«:»。此外,除了那些匹配的字符外,话语的说话人可能还包含其他字符,例如空格或其他任何字符。此外,我不在乎不突出显示冒号本身,我只想要^[:]\+:在要突出显示的第一行中-不是包含冒号的后续行。谢谢!我在Freenode的#vim上使用了一个变体来实现我需要的功能。我应该注意,matchgroup=…必须位于开始和结束之前。下次,请测试您的代码。我显式地放置了
matchgroup=end=
之后加上code>,这样它只适用于以下
start=
,我做了测试。下次,请仔细阅读文档;-)
syntax region screenplayTextSaying start=/\(^\s*\n\)\@<=\_^+\{2,\}:/ end=/^\s*$/
syntax region screenplayTextSaying end=/^\s*$/ matchgroup=screenplayTextAddress start=/\(^\s*\n\)\@<=\_^[^[:+]*:/
"syntax match screenplayTextAddress /[^:]\+:/ Not needed any more!