MacVim NERDCommenter, how to specify alternative d

2019-07-23 21:58发布

问题:

When I'm editing html and xhtml files in MacVim, sometimes I need to comment embedded css styles, so when I try to switch to the alternative set of delimiters ( ca ), the plugin warns me with:

NERDCommenter:cannot use alternative delimiters, none are specified

My question is:

how can I specify these alternative delimiters?

回答1:

These can be specified in the config variable g:NERDCustomDelimiters (before the plugin is sourced, e.g. in your ~/.vimrc):

:let g:NERDCustomDelimiters = {
\ 'html': { 'left': '<!-- ', 'right': '-->', 'leftAlt': '/*', 'rightAlt': '*/' }
\ }


回答2:

Added these lines to my .vimrc :

let g:NERDCustomDelimiters = {
    \ 'html': {  'left': '<!-- ', 'right': '-->', 'leftAlt': '/*','rightAlt': '*/' },
    \ 'xhtml': {  'left': '<!-- ', 'right': '-->', 'leftAlt': '/*','rightAlt': '*/'}, 
\}
let NERD_html_alt_style=1

NOTE: Don't forget about the commas after the curly braces!! :)