Search code examples
vimfzffasd

How you are using outside navigation in VIM with FASD and FZF?


Did you find any comfortable workflow where you use file navigation with FASD or fzf and VIM. I have a problem with getting recent files open in VIM because FASD do not catch them. I'm looking for some tips.


Solution

  • FASD workflow:

    put the following line in your ~/.zshrc

    alias v='f -t -e vim -b viminfo

    Then you can type in terminal

    v myP<TAB>

    to make it tab-complete the recent files of vim

    v myProject

    FZF workflow:

    Put the following script in ~/.zshrc:

    ctrlp() {
      local selected
      if selected=$(find . -type f | grep -v .git | grep -v node_modules | fzf -q "$LBUFFER"); then
        LBUFFER=$selected
      fi  
      zle redisplay
    }
    
    # option-g to find files and put the result in command
    zle -N ctrlp
    bindkey "\eg" ctrlp
    

    Use <option>-g(<alt>-g for windows) to open fzf and select a file. The selected file path will be put in the terminal. Then add vim before the path to open it in vim. More examples can be found at fzf wiki.

    Since fasd doesn't support neovim, I made a similar tool for it. Please check it out: https://github.com/haifengkao/nfasd