Add ALT-ENTER to paste selected items into the buffer

- New fzf#vim#paste inserts selections instead of opening them
  - First item after cursor (space-padded), rest on following lines
  - Leading whitespace stripped only when pasting after text
- Commands opt in via `_paste`; key configurable with g:fzf_vim.paste_key
- Skip the key when buffer is not &modifiable
- Per command, paste:
  - path: Files, GFiles, GFiles?, Buffers, History, Locate
  - line text: Lines, BLines, Marks, Changes
  - matched text: Rg, Ag, Grep
  - tag name: Tags, BTags
  - commit hash: Commits, BCommits
This commit is contained in:
Junegunn Choi
2026-05-31 23:26:55 +09:00
parent e5b53de3d3
commit c2b97c62b9
3 changed files with 183 additions and 5 deletions
+17
View File
@@ -96,6 +96,12 @@ Commands
- Most commands support `CTRL-T` / `CTRL-X` / `CTRL-V` key
bindings to open in a new tab, a new split, or in a new vertical split
- Most commands support `ALT-ENTER` to insert the selected items into the
current buffer instead of opening them. The inserted text depends on the
command: file path (`:Files`, `:GFiles`, `:Buffers`, `:History`, `:Locate`),
line content (`:Lines`, `:BLines`, `:Marks`, `:Changes`), matched text
(`:Rg`, `:Ag`, `:Grep`), tag name (`:Tags`, `:BTags`), or commit hash
(`:Commits`, `:BCommits`)
- Bang-versions of the commands (e.g. `Ag!`) will open fzf in fullscreen
- You can set `g:fzf_vim.command_prefix` to give the same prefix to the commands
- e.g. `let g:fzf_vim.command_prefix = 'Fzf'` and you have `FzfFiles`, etc.
@@ -156,6 +162,17 @@ let g:fzf_vim.preview_window = []
" let g:fzf_vim.preview_bash = 'C:\Git\bin\bash.exe'
```
#### Paste key
Most commands support a key to insert the selected items into the current
buffer instead of opening them (see the command list above for what each
command inserts). Customize it with `g:fzf_vim.paste_key`.
```vim
" Key to insert the selected items into the current buffer (default: 'alt-enter')
let g:fzf_vim.paste_key = 'alt-enter'
```
#### Command-level options
```vim