nerdcommenter icon indicating copy to clipboard operation
nerdcommenter copied to clipboard

Double space delimiter for some languages with g:NERDSpaceDelims=1

Open namedots opened this issue 8 years ago • 6 comments

Python and a few others with a space in the comment string end up having two spaces when setting let g:NERDSpaceDelims=1

I don't agree with having spaces in the Python comment, because someone with g:NERDSpaceDelims=0 would rightly expect not to get an extra space. So I would suggest removing it, but I see that there are those who want it to be there. They're of course wrong, but they're gonna think the same of me and so my other suggestion is:

That g:NERDSpaceDelims=1 doesn't add an extra space when there already is one, that the interpretation of this option is to ensure that there is a trailing space, rather than adding one.

This allows for having a default trailing space for languages like Python where style guides recommend having a space without introducing double spacing for those who prefer to always have a trailing space which is what g:NERDSpaceDelims accommodates

Those who want double spaces could change the comment string to have two spaces, and these would need to adjust their settings, the rest wouldn't.

namedots avatar Dec 31 '16 13:12 namedots

This sounds like a much simpler approach and a great tide over until such a time as somebody takes a stab at all the python related problems.

I would be willing to review and merge any contributions to this effect.

alerque avatar Dec 31 '16 13:12 alerque

temporary lazy workaround:

" vim 8 / neovim HEAD runtime: when ft==python, cms:=#\ %s
"   -- when g:NERDSpaceDelims==1, then NERDComment results in double space
let g:NERDCustomDelimiters = {
      \ 'python': { 'left': '#', 'right': '' }
      \ }

guyhughes avatar Sep 14 '17 21:09 guyhughes

For reference, the other open issue on this topic is #202 which suggests a more exhaustive fix. I'd be willing to accept contributions which either implement the partial fix discussed here or the more complete one there. Note that end users can hack around this according to their won preference as mention by @guyhughes, but I won't be accepting that change to the plugin itself because it breaks to many existing users's configurations out of the box. Thanks for understanding.

alerque avatar Oct 31 '17 17:10 alerque

@alerque I still have the problem with python file.

laixintao avatar Jan 08 '19 07:01 laixintao

This problem still persists (Python).

im-n1 avatar Apr 26 '20 07:04 im-n1

That's why this issue is still open @im-n1 and @laixintao. We will close this issue when it is fixed, but so far nobody has stepped up to actually contribute a proper fix. Note there are two different workarounds in these related issue comments, but neither is something we can integrate into the plugin without breaking other scenarios. We'd be happy to accept a PR that deals with this properly (ala #421).

alerque avatar Apr 27 '20 08:04 alerque