FuzzyFinder Teaser Functions (for finding Files)
" Much like the GetIncludeDirForFF() but for the 'src' directory.
"
function! GetSrcDirForFF(from)
let from = substitute(SanitizeDirForFuzzyFinder(a:from),
\ '/test/.*$', '', '')
return GetDirForFF(from, 'src/')
endfunction
Now, you can use these by making some mappings. I have the following three:
nnoremap ,ff :FuzzyFinderFile<cr>
nnoremap ,ft :FuzzyFinderFile <c-r>=GetTestDirForFF('%:p:h')<cr><cr>
nnoremap ,fi :FuzzyFinderFile <c-r>=GetIncludeDirForFF('%:p:h')<cr><cr>
nnoremap ,fs :FuzzyFinderFile <c-r>=GetSrcDirForFF('%:p:h')<cr><cr>
Clearly this requires that you’re already working on a file somewhere inside the /root/of/code/tree/component_name directory but that’s my convention most of the time when working on a library so this works great for me.
Cheers!
Page 2 of 2 | Previous page
Polprav:
October 16th, 2009 at 10:40 pm
Hello from Russia!
Can I quote a post in your blog with the link to you?
Derek Wyatt:
October 17th, 2009 at 3:29 am
yup
mMontu:
July 11th, 2012 at 7:13 am
Great idea!
Found two small changes needed to work under ms-windows:
function! SanitizeDirForFuzzyFinder(dir)
let dir = expand(a:dir)
if (has(“win16″) || has(“win32″) || has(“win64″))
let dir = substitute(dir, ‘\’, ‘/’, ‘g’)
endif
:
:
function! GetDirForFF(from, addon)
:
:
let dirs = split(from, ‘/’)
if !(has(“win16″) || has(“win32″) || has(“win64″))
let dirs[0] = ‘/’ . dirs[0]
endif
” Walk up the tree and see if it’s anywhere there
for n in range(len(dirs) – 1, 0, -1)
Thanks!