Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to detect and invert block (minimal) comment syntax #295

Open
himat opened this issue Apr 8, 2017 · 1 comment
Open

Add function to detect and invert block (minimal) comment syntax #295

himat opened this issue Apr 8, 2017 · 1 comment
Labels

Comments

@himat
Copy link

himat commented Apr 8, 2017

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 cm to make a multipart comment, and then cu to uncomment, but that's worse, I think, than having a command that would do both instead of the default way for c, which seems to toggle comment line by line.

Is there a way for me to remap c to toggle a block comment?

@alerque
Copy link
Member

alerque commented Apr 8, 2017

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 invoke NERDComSexyComment() can typically be reversed using the \ci binding for NERDComInvertComment(). You don't even have to select the same block, inverting can be done with the cursor anywhere in the block.

@alerque alerque added the feature label Apr 8, 2017
@alerque alerque changed the title How to toggle block comments Add function to detect and invert block (minimal) comment syntax Apr 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants