我使用nerdcommenter來評論代碼。如何使nerdcommenter對待.ctp文件爲.html - VIM
我對<leader>cc
發表評論。當我使用.html文件類型時,它確實很好用。它圍繞着代碼< -代碼- >
但隨着.ctp文件,我不得不改變文件類型由:set filetype=html
第一個HTML,並開始按預期工作,但我的語法高亮變化太快。
有沒有一種方法,使nerdcommenter治療.ctp文件作爲的.html?
我使用nerdcommenter來評論代碼。如何使nerdcommenter對待.ctp文件爲.html - VIM
我對<leader>cc
發表評論。當我使用.html文件類型時,它確實很好用。它圍繞着代碼< -代碼- >
但隨着.ctp文件,我不得不改變文件類型由:set filetype=html
第一個HTML,並開始按預期工作,但我的語法高亮變化太快。
有沒有一種方法,使nerdcommenter治療.ctp文件作爲的.html?
感謝@ryuichiro它被解決了。 Here is the full post。
我們只需要使用替代註釋,如:
let g:NERDCustomDelimiters = {
\ 'php': { 'left': '//', 'leftAlt': '<!--', 'rightAlt': '-->' }
\ }
而且,更改爲替代評論風格,使用<Leader>ca
您可以添加到您的.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
你。
編輯:我想我應該說,我沒有真正嘗試過這個與書呆子,特別是,但如果它使用'commentstring'
像文檔說的,這應該工作。
感謝您的評論。我嘗試了'set commentstring = \「%s set commentstring?',我得到了'commentstring =」%s'但它仍然以相同的方式評論。 – whitesiroi
(+1)非常感謝您的幫助。也許,有一種方法只對nerdtcommente進行更改,因爲我不想更改語法高亮?) – whitesiroi