fzf.vim icon indicating copy to clipboard operation
fzf.vim copied to clipboard

Match exact searched word/phrase

Open vaklinzi opened this issue 4 years ago • 2 comments

  • [x] I 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 would like to find exact matches for a searched word. For example if I search for $user I would like to find only these results but have others like $userData, $username...:

image

image

I tried with ' '$user but still there are some other results.

vaklinzi avatar Jul 08 '20 12:07 vaklinzi

It seems that the search term is in Vim always put in single quotes, since

$FZF_DEFAULT_OPTS 

containing --exact or -x only yields exact matches. That is why in my vimrc I added

let $FZF_DEFAULT_OPTS=substitute($FZF_DEFAULT_OPTS, '\V--exact\|-x', '', 'g')

Regarding this exact issue,

let $FZF_DEFAULT_OPTS .= ' -x '

should achieve what you look for.

Konfekt avatar Aug 31 '21 10:08 Konfekt

I tried with ' '$user but still there are some other results.

It's working as expected. It's only showing results that contain the exact $user, not matching something like $someuser or $ultracondenser.

What you're looking for is a word-boundary anchor (\b in regex), but fzf doesn't support it.

junegunn avatar Sep 01 '21 06:09 junegunn