0

the example given in the official doc is C and I change into python

" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1

" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1

" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'

" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'python': { 'left': '#' } } <==

" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1

" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1

"

but it didn't work when I hit <leader>cc and also don't work by hitting <leader>cu?

besides, how to change the default mapping key for this plugin like change <leader>cc to <leader>c to comment ?

1 Answers1

1

You don't need to teach NERDCommenter about Python; it already knows that the comment prefix is # (and if it didn't, it falls back to Vim's 'commentstring' option, which also knows about Python).

If that does not work, it looks as if your plugin installation is broken.


The remapping is described under :help NERDComMappings. That remapping would be:

map <Leader>c <Plug>NERDCommenterComment

As the other NERDCommenter mappings start with <Leader>c, I would advise against this. As Vim cannot tell whether the mapping is done or you'll keep typing, there will be a delay until the mapping applies. Only way to get rid of that is remapping / deleting all other NERDCommenter mappings. Because of the timeout, the default <Leader>cc is actually faster to execute than what you have in mind.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324