I am a vim user and has nerdcommenter plugin, the problem is when I use <leader>c<space>
to comment out code (also block of code), it prefix # right in front of the code, but pep8 style checker is complaining that I should have a space after the #
eg.
#string = 'abc'
but I want it to comment to:
# string = 'abc'
@IngoKarkatNote: You don't need to hold down the key, just press it like any other key, and release it. Completely the wrong advice for the original question! With NerdCommenter, you DO have to hold down the <leader> key. Otherwise, as OP found, you just end up activating 'change' mode instead.
The NERD Commenter is an indispensable tool when programming in VIM. It understands like a zillion different file types and properly comments each. It can handle single line, multi line, partial line commenting as well as nesting. If you're programming in VIM you really should be using it. It is simple enough to use.
I found that adding the following to my .vimrc
was helpful.
let NERDSpaceDelims=1
This adds the desired extra space for all languages (see "NERDSpaceDelims" at https://github.com/scrooloose/nerdcommenter/blob/master/doc/NERD_commenter.txt)
It appears that the delimiters are hardcoded in the /plugin/NERD_commenter.vim file, starting on line 67. You should be able to change '#' to '# ' for the filetypes that you wish to modify.
UPDATE: I found a more intended and more preferred way of accomplishing this. The plugin has code to handle what it calls CustomDelimiters. You can use something like this in your vimrc to accomplish the same thing as above in a more visible and transferable way:
let g:NERDCustomDelimiters = { 'py' : { 'left': '# ', 'leftAlt': '', 'rightAlt': '' }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With