我有带扩展名的文本文件*.sc
。因此,要对我创建的那种类型的文本文件中的某些关键字进行语法突出显示~/.vim/syntax/sc.cim
。以下是文件内容。
user $ cd ~/.vim/syntax/
user $ cat sc.vim
" Syntax highlightor file for files ending in *.sc
syn keyword basicLanguageKeywords interface channel behavior
user $
我也将以下行添加到 ~/.vimrc
au BufRead,BufNewFile *.sc set filetype=sc
现在,我希望:set syntax=sc
在vim中进行语法高亮显示对*.sc
文件有效。但这是行不通的。
这是怎么了?
如果创建自己的语法组名称(如)basicLanguageKeywords
,则必须为其创建突出显示设置。坚持使用常用名称,以便您的语法设置适用于大多数配色方案。结帐:h group-name
:
To be able to allow each user to pick his favorite set of colors, there must
be preferred names for highlight groups that are common for many languages.
These are the suggested group names (if syntax highlighting works properly
you can see the actual color, except for "Ignore"):
*Comment any comment
*Constant any constant
String a string constant: "this is a string"
Character a character constant: 'c', '\n'
Number a number constant: 234, 0xff
Boolean a boolean constant: TRUE, false
Float a floating point constant: 2.3e10
*Identifier any variable name
Function function name (also: methods for classes)
*Statement any statement
Conditional if, then, else, endif, switch, etc.
Repeat for, do, while, etc.
Label case, default, etc.
Operator "sizeof", "+", "*", etc.
Keyword any other keyword
Exception try, catch, throw
在这种情况下,该值为Keyword
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句