davidkomer
davidkomer

Reputation: 3098

How to keep search window?

Disclaimer: I don't know all the correct terminology here. When I say "window" it might be "quickfix modal dialog" or something.

I am using Neovim (through Neovide) and have these settings to enable search via the fzf plugin, by way of ripgrep:

" Search / Grep
command! -bang -nargs=* Rg
  \ call fzf#vim#grep(
  \   'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
  \   <bang>0 ? fzf#vim#with_preview('up:60%')
  \           : fzf#vim#with_preview('right:50%:hidden', '?'),
  \   <bang>0)

set grepprg=rg\ --vimgrep
" set ctrl-p similarities to open files
nnoremap <silent> <C-t> :Files <cr>
nnoremap <silent> <C-p> :Files <cr>
nnoremap <silent> <C-b> :Buffers<cr>
nnoremap <silent> <C-M-h> :History<cr>
" disable preview window
let g:fzf_preview_window = ''

In my environment vars, I have FZF_DEFAULT_COMMAND set to:

rg --files --hidden --glob "!.git/*"

When I do something like :Rg fn I get a popup window that looks like this:

enter image description here

Here's the problem: when I hit enter to one of the lines to dismiss the window and go to the target file to make changes, I then want to bring the search window back up after I'm done.

I can hit : and then arrow up to re-run the search, but that can be pretty annoying, especially when there are many results and I want to keep the cursor around where it last left off. When I try :copen it's just empty.

Is there a way to re-open the last search in a window, preserving the state? (I understand the search results will be stale if I changed something... that's fine)

Aside for the specific question - I'd appreciate tips for working with search in the Neovim UI, for someone coming from GUI editors like VSCode.

Thanks!

Upvotes: 3

Views: 860

Answers (1)

mickro
mickro

Reputation: 891

I believe that you could be interested by this answer:

The intended usage is to 1) Start the fuzzy search, 2) continue to refine the list of results 3) select the results to take to quickfix (select individual with TAB or select all) then finally 4) Hit ENTER to populate the quickfix with the list.

from https://github.com/junegunn/fzf.vim/issues/808#issuecomment-539234558

Upvotes: 0

Related Questions