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

3 comments on this post.
  1. Polprav:

    Hello from Russia!
    Can I quote a post in your blog with the link to you?

  2. Derek Wyatt:

    yup

  3. mMontu:

    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!

Leave a comment