a plugin for neovim adding a "replaste" operator
|
|
пре 1 година | |
|---|---|---|
| lua | пре 1 година | |
| .gitignore | пре 1 година | |
| LICENSE | пре 1 година | |
| README.md | пре 1 година |
a plugin for neovim adding a "replaste" operator
what the hell does "replaste" mean? Imagine this is your buffer:
{
'thing1': 'value_A',
'thing2': 'another_thing_entirely'
}
and you realize that another_thing_entirely should actually also read value_A to produce this:
{
'thing1': 'value_A',
'thing2': 'value_A'
}
That operation is a "replaste"
To execute a replaste in stock vim you have several choices:
another_thing_entirelyvalue_Ayi' on value_A to put it into the unnamed registerdi' on another_thing_entirely to get rid of itp to paste
p or P and then need to undo and correct that.yi' on value_A to put it into your register"_di' on another_thing_entirely to get rid of it without clobbering the registerp to pasteThe nvim-replaste plugin lets you bind a hotkey to the replaste operator. so if I mapped it to .p then the opertation becomes:
yi' on value_A to put it into your register.pi' on another_thing_entirelyMuch better! The i' motion can be swapped with any motion you might need.
nvim-replaste also has an operator called "swapaste" which swaps the content of the register with the content of your motion. So if the buffer reads:
{
'thing1': 'value_A',
'thing2': 'another_thing_entirely'
}
But you want the buffer to read
{
'thing1': 'another_thing_entirely',
'thing2': 'value_A'
}
Then if swapaste is mapped to .y then the steps are
di' with your cursor on value_A.yi' on another_thing_entirelyp in the hanging quotes where value_A used to beThats it! install and start replasting :)
If you are using lazy.nvim then add this:
{
'https://mygit.link/gwen/nvim-replaste.git',
lazy = false,
opts = {
replasteKey = '<Leader>p',
swapasteKey = '<Leader>y',
},
}
replasteKey and swapasteKey are the first argument to a nmap (or more accurately the second argument of a vim.keymap.set call)
This software was written by a real person. She made it for fun and to be useful for herself. It is licensed as Creative Commons 0. Legally speaking anyone can use it for anything. I truly defy you to turn a profit with this one.
However if you are a capitalist doing capitalist things or a fascist doing fascism:
Get Bent!
You are explicitly unwelcome here. The author thinks that you are a bad person, shame on you.
This software was written for artists, students, hackers, and laborers.
If you are on our side, and are selling your labor then I would ask you to consider: will using this software will help you or will help your boss? If the software is helping you survive the hellscape, then please take it and go on with my blessing. But if it's only going to help your boss, make them pay you to write it instead.
A better world is possible and we are going to build it together <3