3

I know how to fzf.vim, but I'd like to open from terminal.

Grepping history or viminfo may be achieve thst, but I wonder if there is any smart way.

oguz ismail
  • 39,105
  • 12
  • 41
  • 62
Kohei Murakami
  • 319
  • 4
  • 12

4 Answers4

2

This is how you can save the list of recent files from vim to a file:

vim -c "call append(0, v:oldfiles)" -c "write vim-oldfiles.tmp" -c exit

Put v:oldfiles (the list of recent files saved in ~/.viminfo) into the first (new and empty at the start) buffer, write the buffer to a file, exit.

Now you can pass the content of file to fzf.

phd
  • 69,888
  • 11
  • 97
  • 133
0

Not exact solution. But you could open a terminal buffer on the lower part of your vim edit like an IDE and use your terminal fzf

However, not sure if this will let you open a file in a new vim tab

HaffiM
  • 21
  • 3
0

If you're having trouble executing vim on files that have ~ in their path (vim open a new blank file instead of the desired file) because fzf and vim don't expand tilde (~), here's how I do it:

export FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS"
--bind 'ctrl-e:execute(vim -c \"execute \\\"edit\\\" expand({})\" >/dev/tty)'
"

It's trial and error, based on this.

M Imam Pratama
  • 579
  • 7
  • 19
0

I have an zsh autoloaded function called old:

function old(){
    vim -c 'redir >> /tmp/oldfiles.txt | silent oldfiles | redir end | q'
    sed -i '/NvimTree$/d' /tmp/oldfiles.txt
    local fname
    fname=$(awk '/home/ && !/man:/ {print $2}' /tmp/oldfiles.txt | fzf) || return
    vim "$fname"
    \rm /tmp/oldfiles.txt
}
SergioAraujo
  • 10,039
  • 3
  • 48
  • 38