Vim配置中遇到了正则表达式的问题
请教一个问题,vim中配置脚本的时候那些正则表达式是怎么回事?我基本上看不懂:
syn match cFloat display contained "\d\+f"
"floating point number, with dot, optional exponent
syn match cFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
"floating point number, starting with a dot, optional exponent
syn match cFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
"floating point number, without dot, with exponent
syn match cFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>"
if !exists("c_no_c99")
"hexadecimal floating point number, optional leading digits, with dot, with exponent
syn match cFloat display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>"
"hexadecimal floating point number, with leading digits, optional dot, with exponent
syn match cFloat display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>"
endif
上面的代码摘自 vim的默认的c语言语法配置脚本,"floating point number, with dot, optional exponent
syn match cFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
"floating point number, starting with a dot, optional exponent
syn match cFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
"floating point number, without dot, with exponent
syn match cFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>"
if !exists("c_no_c99")
"hexadecimal floating point number, optional leading digits, with dot, with exponent
syn match cFloat display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>"
"hexadecimal floating point number, with leading digits, optional dot, with exponent
syn match cFloat display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>"
endif
"\d\+f" 是不是对应perl中的 <===> m#\d+f#i;
"\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=" <===> m#\d+\.\d*(e[-+]?\d+)?[fl]?#i;
"\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" <===> m#\.\d+(e[-+]?\d+)?[fl]?#i;
vim脚本中 为什么 '量词+' 前面要叫 '\', 而那个 量词'*'又不要。
那些个 '\=' 到底是什么意思,是不是相当于 perl中的 '量词?' ?
我想配置一个适合自己用的vim感觉太难了啊.
[ 本帖最后由 wfoo 于 2011-9-21 19:22 编辑 ]