Skip to content

Instantly share code, notes, and snippets.

@ompugao
Created September 23, 2012 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ompugao/3769638 to your computer and use it in GitHub Desktop.
Save ompugao/3769638 to your computer and use it in GitHub Desktop.
fasd integration to vim
" Z - cd to recent / frequent directories
command! -nargs=* Z :call Z(<f-args>)
function! Z(...)
let cmd = 'fasd -d -l -e printf'
for arg in a:000
let cmd = cmd . ' ' . arg
endfor
let pathes = split(system(cmd),"\n")
for i in range(0,len(pathes)-1)
echo i ." " . pathes[i]
endfor
if len(pathes) == 0
echo "No Directory"
return
elseif len(pathes) == 1
let path=pathes[0]
let ans = input('lcd ' . path . '?[Y/n]')
if ans != "n"
exec "lcd " . path
endif
else
let ans = input('which directory?[num]')
if ans != ""
exec "lcd " . pathes[ans]
endif
endif
endfunction
nmap <Space>z :Z
" F - search and open mru file
command! -nargs=* F :call F(<f-args>)
function! F(...)
let cmd = 'fasd -l -e printf'
for arg in a:000
let cmd = cmd . ' ' . arg
endfor
let pathes = split(system(cmd),"\n")
for i in range(0,len(pathes)-1)
echo i ." " . pathes[i]
endfor
if len(pathes) == 0
echo "No file"
return
elseif len(pathes) == 1
let path=pathes[0]
let ans = input('edit ' . path . '?[Y/n]')
if ans != "n"
exec "edit " . path
endif
else
let ans = input('which file?[num]')
if ans != ""
exec "edit " . pathes[ans]
endif
endif
endfunction
nmap <Space>f :F
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment