Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes it is not highlighted when searching #1197

Open
rmGFW opened this issue Dec 4, 2020 · 3 comments
Open

Sometimes it is not highlighted when searching #1197

rmGFW opened this issue Dec 4, 2020 · 3 comments

Comments

@rmGFW
Copy link

rmGFW commented Dec 4, 2020

search without highlight example
image

search with highlight example
image

@junegunn
Copy link
Owner

junegunn commented Dec 6, 2020

The highlighting you see in the second image is the result of &hlsearch option of Vim (:nohl will clear the highlight). fzf doesn't control how the matches are highlighted in its window. &hlsearch is a global option, so if I'm not mistaken, it's not possible to turn it off only in the fzf window.

@rmGFW
Copy link
Author

rmGFW commented Dec 6, 2020

The highlighting you see in the second image is the result of &hlsearch option of Vim (:nohl will clear the highlight). fzf doesn't control how the matches are highlighted in its window. &hlsearch is a global option, so if I'm not mistaken, it's not possible to turn it off only in the fzf window.

oh , thanks !
but how can I configure the built-in search of fzf to achieve more recognizable text highlighting?

@junegunn
Copy link
Owner

junegunn commented Dec 7, 2020

You want it for all commands, or only for :Rg?

To apply it globally, add some --color options in your $FZF_DEFAULT_OPTS.

# See "man fzf" for more options
export FZF_DEFAULT_OPTS='--color hl:underline:reverse,hl+:underline:reverse'

You can do this in your Vim configuration file

let $FZF_DEFAULT_OPTS = '--color hl:underline:reverse,hl+:underline:reverse'

A few caveats:

To apply the color settings to an individual command, you have to redefine each command using their functions (https://github.com/junegunn/fzf.vim#vim-functions). For example,

command! -bang -nargs=? -complete=dir Files
    \ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': '--color hl:underline:reverse,hl+:underline:reverse'}), <bang>0)

This gives you the maximum flexibility but it can be quite tedious.

junegunn added a commit that referenced this issue Dec 7, 2020
junegunn added a commit to junegunn/fzf that referenced this issue Dec 7, 2020
So you can override the colors and still have the text attributes

    # Default colors and attributes
    fzf

    export FZF_DEFAULT_OPTS='--color hl:-1:underline,hl+:-1:underline:reverse'

    # Default colors with underline+reverse attributes
    fzf

    # Different colors with underline+reverse attributes
    fzf --color hl:176,hl+:177

Related: junegunn/fzf.vim#1197 (comment)
antoinemadec pushed a commit to antoinemadec/fzf.vim that referenced this issue Feb 28, 2021
kralicky pushed a commit to kralicky/fzf that referenced this issue Jun 23, 2021
So you can override the colors and still have the text attributes

    # Default colors and attributes
    fzf

    export FZF_DEFAULT_OPTS='--color hl:-1:underline,hl+:-1:underline:reverse'

    # Default colors with underline+reverse attributes
    fzf

    # Different colors with underline+reverse attributes
    fzf --color hl:176,hl+:177

Related: junegunn/fzf.vim#1197 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants