Closed wangkeunoh closed 3 years ago
From the related question you have found, it's kind of tricky to implement. So you need external tool to only display the filenames. I would suggest you to search how to display only filename with awk and then put the command inside of transformer
variable like this:
let transformer = "| <your-awk-pattern>"
basically treat it like inside of shell, you can try your awk pattern
first inside of your shell like this:
find . -type f | <your-awk-pattern> | fzf
and see if your awk pattern
already match what you want. I use find
command as an example, it basically search any file in the current directory. You can use other command if you want.
After you found the awk pattern
you want, you can use the snippet from the related question you have found. If there's an error about transformer not found
, you can use g:transformer
instead of transformer
variable to make transformer
as global variable instead of local variable.
I'm still learning about awk
command so I'm not sure the right pattern for your case.
@bruhtus Thanks for the comment.
Please note that you don't have to use awk
but any program you are more comfortable with. e.g. sed
, perl
, ruby
, etc.
Also note that by default, you can toggle the preview window by pressing CTRL-/
key. This will help you see the hidden part of the lines.
Another approach would be to move the preview window to the top or the bottom of the window.
" Preview window on the upper side of the window with 40% height, ctrl-/ to toggle
let g:fzf_preview_window = ['up:40%', 'ctrl-/']
" Preview window on the upper side of the window with 40% height,
" hidden by default, ctrl-/ to toggle
let g:fzf_preview_window = ['up:40%:hidden', 'ctrl-/']
g:fzf_preview_window
applies to all commands in this plugin. If that is not what you want and you want different preview window option only for :Rg
, you can redefine :Rg
command like so.
command! -bang -nargs=* Rg
\ call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case -- ".shellescape(<q-args>), 1, fzf#vim#with_preview('up:40%', 'ctrl-/'), <bang>0)
man fzf
)Hello, I like this project very much and I really appreciate it.
But I have some issue to resolve. My work environment has a very long path like the picture below.
I thought there might be a similar issue, so I searched and found and read the article below, but I didn't understand it, so I'm posting the question again.
https://github.com/junegunn/fzf.vim/issues/960 <--- It is very similar to my problem, so I read it well, but it is difficult for me.
What I want is to simply show the file names only instead of all paths in the search results like below
[currently] master/bionic/libc/tzcode/localtime.c|1861 col 61| if (normalize_overflow(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY)) [my goal : I want to custmoize] localtime.c|1861 col 61| if (normalize_overflow(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY))
Is it possible that I want to change? It would be really appreciated if anyone could give me a hint on where to study.
thank you