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

Is it possible to show line number in GFiles ?

Open Syn3iotiC opened this issue 6 years ago • 4 comments

  • 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 screen shot 2561-07-08 at 23 15 11

screen shot 2561-07-08 at 23 15 23

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!

Syn3iotiC avatar Jul 08 '18 16:07 Syn3iotiC

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

badfilms avatar Apr 19 '19 05:04 badfilms

the highlighting of bat is very bad for my color theme. I would much prefer fzf preview to have an option for cat --number.

phongvcao avatar Aug 27 '20 20:08 phongvcao

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.

badfilms avatar Aug 27 '20 20:08 badfilms

how to show line numbers

  1. 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

  2. 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

ElectricRCAircraftGuy avatar Feb 28 '22 18:02 ElectricRCAircraftGuy