junegunn / junegunn/fzf.vim

Remember last searched item and auto paste/replace selected with visual mode for Rg

Open
#1,129 1 comment 3 reactions 0 assignees View on GitHub
Dominant language
Vim Script
Stars
10.3k
Forks
608
Avg merge
5d 8h
Merged PRs (30d)
2

Description

- [x] I have fzf 0.22.0 or above
- [xI have read through https://github.com/junegunn/fzf.vim/blob/master/README.md
- [x] I have read through https://github.com/junegunn/fzf/blob/master/README-VIM.md
- [x] I have read through the manual page of fzf (`man fzf`)
- [x] I have searched through the existing issues

I want fzf rg to behave like Intellij IDEA. When you search for something and press enter, it remembers what you've searched for, and next time you open up the same search window, it will autofill the search bar with what you have typed last time you searched. It also would be helpful to select something with visual line and press the shortcut to open :Rg, and have it pasted into the search bar, or replaced it there was something already (which might happen when we implement the first thing I wrote).

I've tried to implement something like this:

``` viml
command! -bang -nargs=* Rg | call Rg(, 0)

function! Rg(name, bang)
if g:last_rg_search == ""
call fzf#vim#grep('rg --column --line-number --no-heading --color=always --smart-case '.shellescape(a:name), 1, fzf#vim#with_preview('down'), a:bang)
else
call fzf#vim#grep('rg --column --line-number --no-heading --color=always --smart-case '.shellescape(g:last_rg_search), 1, fzf#vim#with_preview('down'), a:bang)
endif
endfunction
```

but with no luck.

Hoping for your ideas.

BTW one of the greatest plugins of all time :+1:

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.