-
Notifications
You must be signed in to change notification settings - Fork 0
License
Geertsky/edit_and_yank.nvim
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
*edit-and-yank.txt* Edit-before-yank operator plugin *edit-and-yank*
==============================================================================
INTRODUCTION *edit-and-yank-intro*
edit-and-yank lets you use a yank-like operator that captures text by any
motion/selection, opens it in a centered floating scratch buffer so you can
edit it, and on :w saves the edited text into your registers (clipboard too)
and closes the float.
- Normal mode: behaves like |y| (operator-pending): gyiw, gyap, gy$ …
- Visual mode: select, then press the mapping (defaults to `gy`).
Requires: Neovim 0.8+ (tested on 0.9/0.10/0.12)
Repo/module name: `edit_and_yank` (Lua: `require('edit_and_yank')`)
==============================================================================
INSTALLATION *edit-and-yank-install*
Using Lazy.nvim: >
{ "Geertsky/edit_and_yank.nvim", config = function()
require("edit_and_yank").setup()
end }
<
==============================================================================
SETUP *edit-and-yank-setup*
Lua: >
require("edit_and_yank").setup({
mapping = "gy", -- normal-mode operator (expr mapping)
visual_mapping = "gy", -- visual-mode mapping
close_on_write = true, -- close float after :w
preserve_filetype = true, -- copy current filetype into scratch
registers = { '"', '+', '*' }, -- registers to fill on :w (also fills "0)
float = {
width_ratio = 0.6, -- 0..1 of editor width
height_ratio = 0.5, -- 0..1 of editor height
border = "rounded", -- see |nvim_open_win()|
},
})
<
==============================================================================
USAGE *edit-and-yank-usage*
Operator (normal mode):
- `gyiw` Edit inner word, then `:w` to copy.
- `gyap` Edit a paragraph, then `:w`.
- `gy$` Edit until end of line, then `:w`.
Visual mode:
1. Make a selection (characterwise, linewise, or blockwise).
2. Press `gy` (or your `visual_mapping`).
3. Edit in the float and `:w` to copy.
In the floating buffer:
- `:w` copies the entire buffer to configured registers and closes (if
|edit-and-yank-config-close_on_write| is true).
- `q` closes the float (local mapping).
- `<C-s>` writes (local mapping in normal/insert).
Registers filled on write:
- unnamed (`"`) if configured
- system clipboard (`+`) and primary selection (`*`) if configured
- yank register `0` (like a real yank)
- correct register type (character/line/block) is preserved
Note: For `+`/`*` to reach your OS clipboard, use a Neovim build with
`+clipboard` and/or set |clipboard|=unnamedplus.
==============================================================================
OPTIONS *edit-and-yank-options*
*edit-and-yank-config-mapping* (string) default: "gy"
*edit-and-yank-config-visual_mapping* (string) default: "gy"
*edit-and-yank-config-close_on_write* (boolean) default: true
*edit-and-yank-config-preserve_filetype* (boolean) default: true
*edit-and-yank-config-registers* (table of strings) default: {'"', '+', '*'}
*edit-and-yank-config-float.width_ratio* (number) default: 0.6
*edit-and-yank-config-float.height_ratio*(number) default: 0.5
*edit-and-yank-config-float.border* (string) default: "rounded"
==============================================================================
TROUBLESHOOTING *edit-and-yank-troubleshooting*
- `invalid escape sequence near '"normal! '` when leaving Visual:
Use termcodes for <Esc>. The plugin already does this.
- Buffer does not close on `:w`:
We close on a scheduled callback after write; ensure `close_on_write = true`.
- `Key is read-only: register` on :w:
We don't set v:register. We write registers via |setreg()| and update `"0`.
- Clipboard not updated:
Ensure a Neovim build with `+clipboard` and consider
`:set clipboard=unnamedplus`.
==============================================================================
CREDITS & LICENSE *edit-and-yank-license*
MIT-style; attribution appreciated.
Author: Geertsky & chatGPT
==============================================================================
vim:tw=78:ts=8:ft=help:norl:
About
No description, website, or topics provided.
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published