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

Syntax Highlighting in the Result Panel

Open damassi opened this issue 9 years ago • 11 comments

It would be great to be able to toggle syntax highlighting in the results pane. Right now the results are printed out in only one color.

damassi avatar Feb 25 '15 17:02 damassi

It's might be a bit hard to determine the file types among the search results.

Menghongli avatar Feb 25 '15 22:02 Menghongli

That's what I figured. This seems like a difficult ask, but it would be a fantastic addition.

damassi avatar Feb 25 '15 22:02 damassi

It is not impossible (by using syntax region) but needs a lot of work.

I'll try to do it sometime, thank you for your suggestion.

dyng avatar Mar 02 '15 07:03 dyng

+1

Leeiio avatar Oct 15 '16 03:10 Leeiio

+1

blayz3r avatar Dec 22 '19 19:12 blayz3r

On a related note, can I change the colours of the results somehow? The highlighted search term is unreadable for me:

image

Note also the trailing white-space highlighted red.

vext01 avatar Mar 11 '20 12:03 vext01

Ah ha! You can customise the match colour with the ctrlsfMatch highlight.

Trailing space issue still stands.

vext01 avatar Mar 11 '20 12:03 vext01

If you are using vim-trailing-whitespace to highlight trailing spaces, please add ctrlsf to its ignoring files.

let g:extra_whitespace_ignored_filetypes = ['ctrlsf']

dyng avatar Mar 11 '20 14:03 dyng

Ah! Thanks.

I think I'm using a hand-rolled solution, but I'm happy to switch to using a plugin.

Thanks!

On Wed, 11 Mar 2020, 15:00 Ye Ding, [email protected] wrote:

If you are using vim-trailing-whitespace to highlight trailing spaces, please add ctrlsf to its ignoring files.

let g:extra_whitespace_ignored_filetypes = ['ctrlsf']

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dyng/ctrlsf.vim/issues/26#issuecomment-597684247, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAETWG4ABFSP3B2UZNSSLVDRG6RPPANCNFSM4A4W7QAQ .

vext01 avatar Mar 11 '20 21:03 vext01

As a workaround, you can maybe try adding something like this to your vimrc:

" Use syntax of current buffer in CtrlSF output
function CtrlSF_syntax_hi()
    let s:syntx = &syntax
    execute ':CtrlSF'
    windo if &ft == 'ctrlsf' | execute 'set syntax='.s:syntx | endif
endfunction

nnoremap <silent> <leader>sf :call CtrlSF_syntax_hi()<CR>

It's not useful if you're trying to grep over many different kinds of files or looking for a specific term, but for use cases where, e.g. you're trying to find all lines in a code base that invoke the function at the cursor, it's fairly handy since it's most likely that results returned will be in the same language as the file you're grepping from.

HawkinsT avatar May 06 '20 16:05 HawkinsT

Syntax highlighting in result pane would be awesome, anyway thanks for this wonderful plugin. Congratulations, so so useful

jugarpeupv avatar Apr 15 '22 15:04 jugarpeupv