junegunn / fzf.vim

fzf :heart: vim
MIT License
9.51k stars 581 forks source link

[Rg] Is there a way to open the file and navigate to a line without having paths and line numbers in the output? #1537

Closed mqrris closed 2 months ago

mqrris commented 2 months ago

rg-error

To reproduce screenshots:

command! -bang -nargs=* Rg call fzf#vim#grep("rg -I -N --trim --color=always --smart-case ".shellescape(<q-args>), 1, <bang>0)
let $FZF_DEFAULT_OPTS="--color='gutter:#000000,bg+:#000000,prompt:#000000' --prompt='' --pointer=' ' --no-info --no-scrollbar --no-separator --reverse"

I'd also liked to know how to remove "Rg>" prompt from Rg and "~/" from FZF.

As well as this padding:

fzf-rg-space

The only reason I'm doing this is to save my screen estate. I know it's probably unfeasible, but I'm gonna ask anyway.

junegunn commented 2 months ago

fzf needs to know the file path and the line number to go to the position, so you can't use an rg command that doesn't print them. However, you can hide the parts using --with-nth option like so.

" command (string), [spec (dict)], [fullscreen (bool)]
command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case -- ".fzf#shellescape(<q-args>), { 'options': '--with-nth 4..' }, <bang>0)

You should note that --with-nth makes fzf slower.

As well as this padding:

Nope, not possible. One column is for "pointer" and another is for "marker" (for --multi selection).