fzf.vim
fzf.vim copied to clipboard
Is it possible to show line number in GFiles ?
- Category
- [x] Question
- [x] Bug ?
- [ ] Suggestion
- OS
- [ ] Linux
- [x] macOS
- [ ] Windows
- [ ] Etc.
- Vim
- [ ] Vim
- [x] Neovim
I added blank line
at line 8, then saved
I wonder if we could config GFiles?
to show absolute line number (without relative like the second picture).
If you notice, the red plus sign should be at the bottom because it's line 8.
My configure is
command! -bang -nargs=* Find call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --follow --color=always '.<q-args>, 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%') : fzf#vim#with_preview('right:50%:hidden', '?'), <bang>0)
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview('right:50%', '?'), <bang>0)
command! -bang -nargs=? -complete=dir GitFiles
Thanks!
By default, the preview window uses cat
, which doesn't have line numbers. You can install bat
or highlight
and get line numbers, syntax highlighting, etc.
https://github.com/junegunn/fzf#preview-window
the highlighting of bat
is very bad for my color theme. I would much prefer fzf preview to have an option for cat --number
.
I should have said "doesn't have line numbers by default." The examples in the preview window section I linked to in the previous comment will all work with cat
flags.
e.g. fzf --preview 'cat -n {}'
or for a more Vim-specific example,
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', 'cat -n {}']}, <bang>0)
As an aside, you can actually make your own themes for bat
and highlight
that will match (if not true color) your Vim theme. Additionally, you can disable the syntax highlighting altogether if preferred and still take advantage of some of the other features.
how to show line numbers
-
My
git diffn
program shows line numbers in git diff files: https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles/blob/master/useful_scripts/README_git-diffn.md -
You can show line numbers in any text file you fuzzy search like this:
# show line numbers grep -n '' "path/to/file.txt" | fzf # (contrast the above to this, which does not show line numbers) cat "path/to/file.txt" | fzf
See where I first wrote this here: https://github.com/junegunn/fzf/issues/1034#issuecomment-1054558594