Created
September 23, 2012 10:34
-
-
Save ompugao/3769638 to your computer and use it in GitHub Desktop.
fasd integration to vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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