vim-commentary icon indicating copy to clipboard operation
vim-commentary copied to clipboard

Possible to comment without space?

Open x3rAx opened this issue 4 years ago • 2 comments

First, thank you for this plugin, it made my life so much easier ❤️

I have an issue though:

I like "real" comments (ie. text describing what the code does) to have a space between the comment symbol and the actual text:

# This is a comment describing what the highly optimized, but
# unreadable code below does.
this.is(() => some.magic(code)) && nobody += understands[it]

On the other hand, I want commented out code, that is temporarily disabled to not have a space between the comment symbol and the code:

#this.code = should[not].be(executed)

This second case is usually what I use this extension for, because when I write comments, I start by manually typing the comment symbol before typing the text.

Is there a setting that I can change to make this extension not insert a space after the comment symbol when toggling comments?


Edit

Seems like there have been similar threads like this one (#40, #3, #32, #33) and it sounds like there has been some changes regarding to a commentary_format variable but I was unable to find out what value it must be set to, to enable what I requested...

x3rAx avatar May 14 '21 10:05 x3rAx

I think you do it like this (better use after/ftplugin directory, this is just an example):

autocmd FileType c :let b:commentary_format = '/*%s*/'

Maybe even:

autocmd FileType * :let b:commentary_format = &commentstring

xaizek avatar May 14 '21 12:05 xaizek

autocmd FileType * :let b:commentary_format = &commentstring

@xaizek thanks a lot, this is what I was looking for!

Also thanks for the hint about after/ftplugin, I didn't know about that 😅

x3rAx avatar May 14 '21 17:05 x3rAx