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.
-
2_I have a problem with getting recent files open in VIM_ check this https://github.com/mhinz/vim-startify. Probably your question is off-topic. – Roman Kiselenko Apr 21 '16 at 07:34
-
I don't have any problem with fasd or fzf or qs,dqsdg because I don't use them. Learn to use Vim's built-in commands instead. – romainl Apr 21 '16 at 16:47
2 Answers
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

- 5,219
- 2
- 27
- 38
-
-
@regedarek I don't have this line in my .zshrc. I use oh-my-zsh plugins intead. `plugins=(git zsh-syntax-highlighting vi-mode zle-vi-visual opp surround fasd zsh-completions)` – Hai Feng Kao Aug 11 '16 at 09:06
Extremely fast way to navigate ZSH in terminal is combination of FASD, FZF, VIM and CD.
Add script to ~/.zshrc
fasd-fzf-cd-vi() {
item="$(fasd -Rl "$1" | fzf -1 -0 --no-sort +m)"
if [[ -d ${item} ]]; then
cd "${item}" || return 1
elif [[ -f ${item} ]]; then
(vi "${item}" < /dev/tty) || return 1
else
return 1
fi
zle accept-line
}
zle -N fasd-fzf-cd-vi
bindkey '^e' fasd-fzf-cd-vi
Keyboard shortcut 'Ctrl+E'
to run it, can be changed in bindkey '^e'
.
It searchs (fzf) through recent (fasd) files/folders and depending on file type, navigate to directory (cd) or open file with text editor (vim).
Also check other usefull tips and tricks for fast navigation inside terminal https://github.com/webdev4422/.dotfiles

- 113
- 8
-
I found it more user-friendly to run `zle reset-prompt` at the end, as suggested in [zsh: refresh prompt after running zle widget](https://stackoverflow.com/q/52325626/1333025). – Petr Jul 05 '22 at 09:51