Fasd is a command-line tool that enhances productivity by providing quick access to files and directories. It is inspired by autojump, z and v.
By using the code provided below, you can configure Vim to leverage Fasd for swiftly jumping to directories:
" Language: Vim script
" Description: Vim Fasd integration
" Usage: Execute the command:
" :Fasd <QUERY>
" License: MIT
" Author: James Cherti
" URL: https://www.jamescherti.com/vim-fasd-integration
function! Fasd(query)
" -d: Match directories only.
" -l: List paths without scores.
let l:cmd = 'fasd -d -l ' . shellescape(a:query)
let l:result = systemlist(l:cmd)
if v:shell_error !=# 0
echoerr 'Fasd error: ' . join(l:result, "\n")
return
endif
if len(l:result) ==# 0 || !isdirectory(l:result[0])
echo 'Fasd has not found anything for: ' . a:query
return
endif
let l:path = l:result[0]
exec 'edit ' . fnameescape(l:path)
exec 'lcd ' . fnameescape(l:path)
echo l:path
endfunction
command! -bar -nargs=1 Fasd call Fasd(<f-args>)
Code language: Vim Script (vim)