简短版本:我试图在let my_regex = "some regex"
autocmd Syntax * syn match CamelCase my_regex transparent containedin=.*Comment.*,.*String.*,VimwikiLink contains=@NoSpell contained
my_regex
但显然不起作用 - 变量" ignore camel case "
let vim_spellcheck_ignore_words = "\(\<\|_\)\%(\u\l*\)\{2,}\(\>\|_\)\|\<\%(\l\l*\)\%(\u\l*\)\{1,}\>"
" ignore upper-case only words "
let vim_spellcheck_ignore_words = vim_spellcheck_ignore_words . "\|\<[A-Z]*\>"
" ignore words, which contain '_' or a digit "
let vim_spellcheck_ignore_words = vim_spellcheck_ignore_words . "\|\<[a-zA-Z_]*[0-9_]\+[0-9a-zA-Z_]*\>"
" something ese .. "
let vim_spellcheck_ignore_words = vim_spellcheck_ignore_words . "something"
autocmd Syntax * syn match CamelCase vim_spellcheck_ignore_words transparent containedin=.*Comment.*,.*String.*,VimwikiLink contains=@NoSpell contained
未被扩展或识别。如果我直接用它的内容替换变量 - 它完美地工作。我在这里失踪了什么?
故事:谷歌搜索后,我找到了一个技巧here,这使得vim的拼写检查忽略了驼峰的单词(上部和下部)。但我扩展正则表达式忽略了其他几个单词,表达式变得非常难看。所以,我试图做这样的事情:
" begin regex "
let vim_spellcheck_ignore_words = "/"
" ignore upper and lower camel case words "
let vim_spellcheck_ignore_words = vim_spellcheck_ignore_words . "\\(\\<\\|_\\)\\%(\\u\\l*\\)\\{2,}\\(\\>\\|_\\)\\|\\<\\%(\\l\\l*\\)\\%(\\u\\l*\\)\\{1,}\\>"
" ignore all-caps words "
let vim_spellcheck_ignore_words = vim_spellcheck_ignore_words . "\\|\\<[A-Z]*\\>"
" ignore words, which contain a digit or '_' "
let vim_spellcheck_ignore_words = vim_spellcheck_ignore_words . "\\|\\<[a-zA-Z_]*[0-9_]\\+[0-9a-zA-Z_]*\\>"
" end of regex "
let vim_spellcheck_ignore_words = vim_spellcheck_ignore_words . "/"
autocmd Syntax * exe "syn match CamelCase" vim_spellcheck_ignore_words "transparent containedin=.*Comment.*,.*String.*,VimwikiLink contains=@NoSpell contained"
//
解决方案摘要(基于初始方法):
exe
execute
(autocmd Syntax * syn match CamelCase
\ "\(\<\|_\)\%(\u\l*\)\{2,}\(\>\|_\)\|\<\%(\l\l*\)\%(\u\l*\)\{1,}\>
\ \|\<[A-Z]*\>
\ \|\<[a-zA-Z_]*[0-9_]\+[0-9a-zA-Z_]*\>"
\ transparent containedin=.*Comment.*,.*String.*,VimwikiLink contains=@NoSpell contained
)来评估表达式替代:
ImageView magImage = (ImageView)searchView.findViewById(android.support.v7.appcompat.R.id.search_mag_icon);
magImage.setVisibility(View.GONE);
答案 0 :(得分:2)
syn
不期望表达式。我无法准确记住ex :exe
:let
和:echo
命令系列中的exc命令。因此,如果您想使用变量,必须使用:exe
命令来插入变量:
autocmd Syntax * exe "syn match CamelCase" my_regex "transparent containedin=.*Comment.*,.*String.*,VimwikiLink contains=@NoSpell contained"
答案 1 :(得分:1)
我希望我理解你的问题。
To&#34; build&#34;你的命令/ autocmd是动态的,你可以使用:execute
之类的:
autocmd Syntax * exe "syn match CamelCase " . variable ." .... rest commands"