1

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?

Bobby Wan-Kenobi
  • 885
  • 9
  • 18

2 Answers2

3

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': '*/' }
\ }
Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • I did that, and I also put this line after: let NERD_html_alt_style=1 And it worked, but strangely this morning it doesn't. I didn't install any other plugin or did any change to .vimrc I'm using MacVim by the way. – Bobby Wan-Kenobi Mar 09 '13 at 13:52
  • Well, after reading my last comment it occurred to me, hey, put those lines in **.gvimrc** , I did it and it seems it's working. – Bobby Wan-Kenobi Mar 09 '13 at 14:09
  • It stopped working on **MacVim**, it only works in **vim**. I don't know how is that possible, I have that lines in both **.vimrc** and **.gvimrc**. Any ideas? – Bobby Wan-Kenobi Mar 09 '13 at 21:12
  • .gvimrc shouldn't work, it is sourced _last_, after the plugin. Check with `:scriptnames`; it must come _before_ the NERDCommenter plugin! – Ingo Karkat Mar 09 '13 at 21:59
  • I have those lines you gave me in my **.vimrc** before the NerdCommenter itself is sourced, and since I'm using pathogen to source all my plugins, that means that the lines go before pathogen lines, am I right? I guess I am, because the plugin works **perfectly** when I'm running vim inside the terminal.(I can switch between alt comments without any problem) The problem comes when I'm using **MacVim**, I type ca and: **NERDCommenter:cannot use alternative delimiters, none are specified** – Bobby Wan-Kenobi Mar 11 '13 at 17:24
  • I don't know MacVim, but as I said, `:scriptnames` should tell you the order in which things have been sourced. – Ingo Karkat Mar 11 '13 at 17:32
  • Oh my gosh! It has worked all the time, thing is I think it didn't because sometimes I was trying it with **xhtml files** I didn't realize it until I typed **:set filetype?** and vim answered **filetype=xhtml** so it works for html, my question is now, how do I set it up to xhtml as well? – Bobby Wan-Kenobi Mar 11 '13 at 17:47
3

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!! :)

Bobby Wan-Kenobi
  • 885
  • 9
  • 18