tpope / vim-commentary

commentary.vim: comment stuff out
http://www.vim.org/scripts/script.php?script_id=3695
5.9k stars 214 forks source link

Possible to comment without space? #145

Open x3rAx opened 3 years ago

x3rAx commented 3 years ago

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...

xaizek commented 3 years ago

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
x3rAx commented 3 years ago
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 😅