开发者

Adding new filetype to NERD Commenter

开发者 https://www.devze.com 2023-01-29 15:53 出处:网络
I\'m using NERD Commenter. I want to add a new filetype to it. In the latest version, the filetypes definitions start in line 69. I want to add delimiters for .pde (Arduino). Since .pde files follow t

I'm using NERD Commenter. I want to add a new filetype to it. In the latest version, the filetypes definitions start in line 69. I want to add delimiters for .pde (Arduino). Since .pde files follow the same style as C++, I'm just copying the C++ line (line 115) and changing the extension. It looks like this:

....    
....    
\ 'pde': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
....    
....

And that seems right. However, I cannot get i开发者_开发知识库t to work when I open a .pde file. Instead of using '//', it uses '#'. Am I missing something?

Thanks!

UPDATE: It seems I'm doing it write. Look at the commit for when they added commenting support for gsp. They are just doing the same as me. Hmmm....


It is probably because the filetype pde does not exist in filetype.vim.

Basically you have to create you own filetype.vim in ~/.vim/ (which will be sourced before the system filetype.vim), or add to your .vimrc:
" Arduino files
au BufNewFile,BufRead *.pde setf pde

(On the other hand, gspdoes already exist in the default filetype.vim on line 763
" GNU Server Pages
au BufNewFile,BufRead *.gsp setf gsp
)

See :help new-filetype for more information on ways to implement a new file type.

0

精彩评论

暂无评论...
验证码 换一张
取 消