-
Notifications
You must be signed in to change notification settings - Fork 25
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
Allow for visual selection override #128
Comments
I think it should be possible to add, just hasn't been done :) I'm not sure I'll have time in the near future so if anyone wants to take a stab at this feel free to :) |
So the first problem is that I used a mapping of However, the pasted text is inserted before of after the cursor, but it does not overwrite the visual selection. So I will look into the code to see whether this can be adapted in a reasonable amount of effort. |
According to this comment, it might not be possible in neoclip at all, but needs to be handled outside of neoclip. The problem is that you loose the visual selection as soon as Telescope opens. So one solution could be to write a function that saves the visual selection somewhere and on select of a neoclip entry select the visual range again. |
So I made it work with the following: Visual keymap: Custom neoclip action: local function visual_paste(opts)
local handlers = require("neoclip.handlers")
handlers.set_registers({ 'z' }, opts.entry)
vim.api.nvim_feedkeys('gv"zp', "n", false)
end
require("neoclip").setup({
-- ...
keys = {
telescope = {
n = {
custom = {
["v"] = visual_paste
},
},
i = {
custom = {
["<c-v>"] = visual_paste
},
},
},
},
}) @AckslD Should I contribute this to the README? |
Nice @peterfication! I think it would be great to support this natively, would you like to add an PR for that? Otherwise I can give it a shot when I find the time. Let me know :) |
Closes AckslD#128
I gave it a try :) => Let's continue the discussion there. |
Closes AckslD#128
Closes AckslD#128
Closes AckslD#128
I often select a certain word and want to replace it with a paste. Unfortunately, I can't use neoclip properly yet when doing this because it says "No visual range allowed".
I could fake it with a visual keymap to
d:Telescope neoclip<CR>
, which first deletes the selected word and then opens Neoclip. However, if I cancel, the word will be deleted anyways.Is it somehow possible to add a visual range? Or is it too complex?
The text was updated successfully, but these errors were encountered: