nerdcommenter
nerdcommenter copied to clipboard
Add function to detect and invert block (minimal) comment syntax
I really don't understand how a popular plugin like this wouldn't have a simple way to toggle block comments with one command.
I could use
Is there a way for me to remap
The m in \cm
doesn't stand for multi-part (or even multi-line) it stands for minimal and is bound to NERDComMinimalComment()
. This is a very tricky comment syntax to deal with in most languages. Creating it is easy, but finding them and reversing the state is very difficult to parse. This plugin currently doesn't have enough parsing smarts to handle that. If you'd like to contribute the feature we'd love to have it.
If you are doing development work and need to toggle blocks on and off I can suggest a couple approaches:
- Figure out how to the language can be used to guard blocks of code by toggling comments on just one line.
- Use the line by line comment syntax. You can still select regions in vim and toggle them all at once, but the single line comment syntax is a lot easier to parse and revert.
- Use the "sexy" comment syntax if your language supports it. This usually functions the same way as the minimal block comment syntax but uses extra characters to visually denote the comment block. This makes it a lot easier to parse and find what's part of the same block vs. what might not even be comment syntax at all. Comments created using the
\cs
command to invokeNERDComSexyComment()
can typically be reversed using the\ci
binding forNERDComInvertComment()
. You don't even have to select the same block, inverting can be done with the cursor anywhere in the block.