Replies: 2 comments
-
Not exactly what you are looking for, but you can do anything inside I am not sure how to properly achieve similar with built-in commenting. In Visual mode it can be done with |
Beta Was this translation helpful? Give feedback.
-
For anyone else who runs into this, if you're willing to rely on implementation details of the original PR, then this works: _G.__commentyank = function(mode)
if mode == nil then
vim.o.operatorfunc = 'v:lua.__commentyank'
return 'g@'
end
local mark_from, mark_to = "'[", "']"
local lnum_from, col_from = vim.fn.line(mark_from), vim.fn.col(mark_from)
local lnum_to, col_to = vim.fn.line(mark_to), vim.fn.col(mark_to)
if (lnum_from > lnum_to) or (lnum_from == lnum_to and col_from > col_to) then
return
end
local l = vim.api.nvim_buf_get_lines(0, lnum_from - 1, lnum_to, false)
vim.fn.setreg(vim.v.register, l)
-- WARN: Relying on implementation details of `gc`.
require('vim._comment').toggle_lines(lnum_from, lnum_to, vim.api.nvim_win_get_cursor(0))
return ''
end Then it's enough to map |
Beta Was this translation helpful? Give feedback.
-
Was wondering if it's possible to implement this using
mini.comment
or even with the now built-in comment mapping. I'm unfortunately not familiar enough with vimscript to figure out how to cleanly do this.I've implemented this in cherryman/vim-commentary-yank, but looking for a neovim specific solution.
Beta Was this translation helpful? Give feedback.
All reactions