如何使nerdcommenter将.ctp文件视为.html-VIM
我使用注释代码 我通过如何使nerdcommenter将.ctp文件视为.html-VIM,vim,Vim,我使用注释代码 我通过cc发表评论。当我使用.html文件类型时,它确实非常有效。它用 但是对于.ctp文件,我必须首先通过:set filetype=html将文件类型更改为html,然后它开始按预期工作,但我的语法也会突出显示更改 有没有办法使nerdcommenter将.ctp文件视为.html?您可以将其添加到.vimrc au BufNewFile,BufRead *.ctp set filetype=html 通过这一行,您可以让vim根据文件扩展名自动分配文件类型。Nerdcom
cc
发表评论。当我使用.html文件类型时,它确实非常有效。它用
但是对于.ctp文件,我必须首先通过:set filetype=html
将文件类型更改为html,然后它开始按预期工作,但我的语法也会突出显示更改
有没有办法使nerdcommenter将.ctp文件视为.html?您可以将其添加到
.vimrc
au BufNewFile,BufRead *.ctp set filetype=html
通过这一行,您可以让vim根据文件扩展名自动分配文件类型。Nerdcommenter使用
'commentstring'
设置来确定要使用哪种注释<代码>:h“commentstring”给出了以下内容:
*'commentstring'* *'cms'* *E537*
'commentstring' 'cms' string (default "/*%s*/")
local to buffer
{not in Vi}
{not available when compiled without the |+folding|
feature}
A template for a comment. The "%s" in the value is replaced with the
comment text.
您可以使用:setlocal cms
更改活动缓冲区的注释字符串,甚至在打开相应的文件类型时为您使用自动命令设置:setlocal
编辑:我想我应该说,我还没有特别尝试过nerdcommenter,但是如果它像文档中所说的那样使用
'commentstring'
,这应该是可行的。多亏了@ryuichiro,它才得以解决
我们只需使用其他评论,如:
let g:NERDCustomDelimiters = {
\ 'php': { 'left': '//', 'leftAlt': '<!--', 'rightAlt': '-->' }
\ }
让g:NERDCustomDelimiters={
\'php':{'left':'/','leftAlt':'''}
\ }
并且,要更改为其他注释样式,请使用ca
非常感谢你的帮助。也许,有一种方法可以只为NerdComment更改它,因为我不想更改语法突出显示?)谢谢您的评论。我尝试了
set commentstring=\%s set commentstring?
并且得到了commentstring=“%s
,但它仍然以相同的方式进行注释。