kommentary icon indicating copy to clipboard operation
kommentary copied to clipboard

Feature request: comment a part of line out

Open mawkler opened this issue 2 years ago • 3 comments

NERDCommenter has the ability to comment out a part of a line. For instance, if I have the following html file:

lorem ipsium dolor sit amet

, and I select ipsum dolor in visual mode and trigger <Plug>kommentary_visual_default I would like for it to cause the following:

lorem <!-- ipsium dolor --> sit amet

However, currently this plugin only seems operate on full lines, which causes this instead:

<!-- lorem ipsium dolor sit amet-->

mawkler avatar Jul 26 '21 10:07 mawkler

Hi, this would be a really cool feature, unfortunately it would also take quite a bit of time to implement properly.

I don't think I'll work on this anytime soon, however I'd be more than happy to accept contributions..

b3nj5m1n avatar Jul 27 '21 11:07 b3nj5m1n

@b3nj5m1n The primary reason I want this feature is I so that I can create a mapping <leader>C to comment out everything to the right of the cursor. Perhaps that is an easier feature to implement? Is that something that could be added natively to kommentary?

To illustrate, with the cursor on the first character of dolor, pressing <leader>C would cause the following text

lorem ipsium dolor sit amet

to change into this:

lorem ipsium <!-- dolor sit amet -->

For single-line comments one just has to insert the commentstring at the cursor position, but for multi-line strings like in the example above it's trickier I guess.

mawkler avatar Jul 28 '21 10:07 mawkler

+1 for this feature. I use gciw and gcf, a lot with https://github.com/tomtom/tcomment_vim (commenting out individual function parameters).

knpwrs avatar Sep 15 '21 21:09 knpwrs

Hi, thanks for your interest in kommentary, unfortunately I'll not be adding any new features, I'm sorry I never got to this issue.

If you're not aware of it yet, take a look at https://github.com/numToStr/Comment.nvim.

b3nj5m1n avatar Nov 05 '22 04:11 b3nj5m1n