terrortylor / nvim-comment

A comment toggler for Neovim, written in Lua
MIT License
479 stars 23 forks source link

Support keymap for {n}gcc #11

Closed jrock2004 closed 3 years ago

jrock2004 commented 3 years ago

I am looking that something tpope commentary plugin has where I can do 4gcc which would comment current line plus 3 more. I see there is gc4j. Maybe there is a way I could do this already and I just need to create the map myself

terrortylor commented 3 years ago

You could use the mapping: nmap <expr> gcc (v:count? ':CommentToggle<CR>' : ':set operatorfunc=CommentOperator<CR>g@') Although there is no dot repeat on this, where as gc4j does repeat (Something I need to work on)

winston0410 commented 3 years ago

+1 for this feature. By the way thank you for this awesome plugin.

terrortylor commented 3 years ago

Hey going to close this, @winston0410 had a sort of solution but it actually broke v <0.5 compatability which I'm trying to keep atm. you can do 4gcc but as mentioned breaks dot repeatable and see an 4 actions (i.e. have to undo 4 times). But what is supported is gc4j and gc4k etc

asmodeus812 commented 2 years ago

@terrortylor Coming back to this issue, as i also stumbled upon this. In general, the operation is a bit inconsistent with how the rest of the vim operations work, and even other nvim plugins which introduce custom operations - such as nvim substitute. Usually all operations are prefixed by the number of times you want to repeat them while here that is not the case and i find it very confusing and unnatural. For example things like 4gcc vs gc4j or 4gcip vs gc4ip . Correct me if im wrong but this is the only operation that works like that, is there a way to make it customizable and allow us to switch / choose which one to use in the setup for example ?