将formatoptions
设置为包含o
标志时,在注释行上按o
或O
将"继承"前导注释标记。
然而,对于Stata
,只有\
被认定为"有效注释"。另外两种类型的评论被set formatoptions+=o
忽略了。
我可以命名多个前导字符/字符串作为Vim中的"注释标记"吗?以下是如何在Stata
的语法文件中定义"注释行"。
(来自C:/vim/vimfiles/syntax/stata.vim
)
" comments - single line
" note that the triple slash continuing line comment comes free
syn region stataStarComment start=/^s**/ end=/$/ contains=stataComment oneline
syn region stataSlashComment start="s//" end=/$/ contains=stataComment oneline
syn region stataSlashComment start="^//" end=/$/ contains=stataComment oneline
" comments - multiple line
syn region stataComment start="/*" end="*/" contains=stataComment
我看不出//
作为标记有什么特别之处,至少在语法文件中是这样。
提前谢谢。
您要查找的设置是comments
设置。
由于stata文件似乎没有文件类型插件,所以没有人设置它,它保持在默认值(这不是很好)。
由于stata注释与c相似,我们可以看看c是如何处理注释的。在$VIMRUNTIME/ftplugin/c.vim
中我们发现
setlocal comments=sO:* -,mO:* ,exO:*/,s1:/*,mb:*,ex:*/,://
如果将其添加到~/.vim/ftplugin/stata.vim
中,则应该将c风格的注释添加到stata文件中。(这似乎可以处理所有三种类型,即使前导*
不是有效的c注释。)
相关帮助主题:h 'comments'
和:h format-comments
。第二个帮助主题将解释comments
的所有选项。