Closed JoydeepMallick closed 3 months ago
Is it limited to current directory only using
:Rg [PATTERN]
Yes. The default implementation of :Rg
command treats the whole arguments as a single pattern string.
This allows you to omit quotes when you search for a query with spaces or quote characters. I find it extremely useful when searching for lines that print logs.
:Rg cannot proceed
:Rg "Failed to
But you can override this behavior by redefining :Rg
command or defining a command with a different name, so each argument is directly passed to the ripgrep process.
command! -complete=file -bang -nargs=* Rg
\ call fzf#vim#grep("rg --with-filename --column --line-number --no-heading --color=always --smart-case -- ".<q-args>, fzf#vim#with_preview(), <bang>0)
[!NOTE] Compared to this original
:Rg
,
--with-filename
was added so that the file name is always printed even when you pass a file pathfzf#shellescape
around<q-args>
is removed
With this version, you can do something like :Rg pattern ./location/to/file.extension
, but :Rg
(no arguments), :Rg cannot proceed
(query string with spaces), :Rg "Failed to
(query string with quote characters), etc will no longer work. So you probably want to define it with a different name.
Idea: this seems to be a common use-case. Can fzf.vim
add a new command called :RG
that behaves like that?
In other words, out-of-the-box people will have :Rg
that behaves as usual, and :RG
that allows specifying files.
man fzf
)OS :- Windows 10 Enterprise Vim :- VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Feb 1 2023 23:55:13) MS-Windows 64-bit console version Included patches: 1-1273 Compiled by appveyor@APPVEYOR-VM
Issue
I have
ripgep
for windows installed and performing something likerg pattern ./location/to/file.extension
works great.Now as mentioned in readme
:Rg
needs ripgrep installed and usage is mentioned as:Rg [PATTERN]
which works great and returns all possible matches in current working directory. But I want to achieve the similar thing for specific files or folders by mentioning them which does not work as intended.In vim
:Rg pattern ./location/to/file.extension
gives me [Command Failed: rg --column --line-number --no-heading ...].Doubts
Is this not possible in :Rg of FZF ? Is it limited to current directory only using
:Rg [PATTERN]
.Tried making a remap to search for current word under cursor in current file only with this feature if available :-
It gives the same error as when doing it manually like
:Rg pattern ./location/to/file.extension
.