Is there a way to toggle comments in a selected region? seems silly to have to explicitly comment or uncomment a selection instead of just toggling the comment status based on the first line of the selection being commented or not.
@fiveNinePlusR This is not implemented in the standard Vim because different language have different commenting scheme, however it is possible to bind VsVim commands to Visual Studio toggle comment command.
Thanks. I had to find another extension to do this actually because there is no built in method for toggling though there are two for comment and uncomment.
https://marketplace.visualstudio.com/items?itemName=munyabe.ToggleComment
@fiveNinePlusR I think you can still leave this opened, because this can be possibly implemented into VsVim.
The code here may helps this implementation.
https://github.com/munyabe/ToggleComment/blob/master/ToggleComment/ToggleCommentCommand.cs
Closing as this doesn't appear to be core vim functionality that needs to be replicated.
@jaredpar Nonetheless, VSCodeVim did implement this feature, check it out HERE
Although VsCodeVim did implement it, using an external vim plugin as inspiration, it doesn't necesserily mean VsVim should... different maintainers, different audiences, different number of (active) contributors.
That said, I personally found that the aforementioned ToggleComment extension works well. I'm hoping we can use it withing vsvim with the help of a custom binding. I got the following binding to work:
:nmap gc :vsc Edit.ToggleComment<CR>
But, unfortunately, could not toggle multiple lines with visual mode ... would the mapping be different in this case?
I know this is old, but for any weary vim'ers who stumble this way, you can do this in visual mode as well:
:vmap gc :vsc Edit.ToggleComment<CR>
Now, if we could work out that Ctrl-/ issue. :(
I still don't know the difference between map and noremap, so I can't comment on that.
@tobarja Thanks for the heads up tho ;)
i found this explanation which describes just what the noremap does :)
Cheers!
Hey there, thanks for the guidance in this subject.
Just an update...
ToggleComment command is ToogleLineComment in the current version 1.8 of ToggleComment.
So new mappings would be:
For normal mode: :nmap gc :vsc Edit.ToggleLineComment<CR>
For visual mode: :vmap gc :vsc Edit.ToggleLineComment<CR>
Most helpful comment
Thanks. I had to find another extension to do this actually because there is no built in method for toggling though there are two for comment and uncomment.
https://marketplace.visualstudio.com/items?itemName=munyabe.ToggleComment