I’ve read and suffered and failed for a good amount of hours. Nothing “just works” that I try, it works maybe 80%.
After a decade + of using MacVim I decided to go through my config/plugins in detail and freshen/clean everything up, and that includes fixing common annoyances that I’ve tolerated.
If it matters, I’m using Neovide and remapping to paste.
Heres my current nightmare of attempts. Note that they dont really work properly, I just wanted to show the context of how im binding the keys.
vim.keymap.set('v', '<D-v>', '"+P`]') -- paste visual mode
vim.keymap.set('c', '<D-v>', '<C-r>+') -- paste command mode
-- create arbitrary _ char to avoid autoindent issues
vim.keymap.set('i', '<D-v>', '_<ESC>xi<C-r><C-o>+') -- paste insert mode <C-r><C-o>+
vim.keymap.set('n', '<D-v>', 'i<C-r><C-o>+<ESC>l') -- paste normal mode m0"+P`]m`v`0=``
One of the big ones is things don’t indent properly that I paste.
Ideally, it should ignore the indentation of what I paste, by running the =
command in the context of my code.
Consider copying a part of a Lua neovim plugin config from github, so you start the cursor here:
{
{
{ <-- copy this block only, start cursor before the |{
some = 'thing'
},
}
}
It will actually look like this:
{ <-- copy this block only, start cursor before the |{
some = 'thing'
},
This is just a side example of the headaches of trusting the indentation of the thing you’re copying.
So that leaves indenting it ourself.
I’ve read that <C-r><C-p>+
works but it doesnt for me unless I’m doing it wrong.
My next thought is “what if i use marks and just indent it myself?”
One way is to use the `]
and `[
marks to move to the start/end of the pastel the problem is ONCE its indented, you can’t return your cursor to immediately after what was just pasted, which is ridiculous.
What am I missing and why is this such a pain in the ass?