I made a little vimscript to automatically cd to the project root of a symfony project. It makes it easier for me to use the ctags :-)
"-------------------------------------------------------------------------------
" Description: Finds and cd to the symfony root of the project
" Copyright: Copyright (C) 2009 Geoffrey Bachelet
" Maintainer: Geoffrey Bachelet
" Version: 1.0
"-------------------------------------------------------------------------------
if exists('find_symfony_root_loaded')
finish
endif
let find_symfony_root_loaded = 1
if ! exists('find_symfony_root_symfony_executable')
let find_symfony_root_symfony_executable = 'symfony'
endif
" root detection when opening a new vim seems to work
" only if these two events are bound. not sure why.
autocmd BufWinEnter,BufRead * call FindSymfonyRoot()
function FindSymfonyRoot()
let l:cwd = GetAbsoluteDirname(@%)
let l:symfony_root = findfile(g:find_symfony_root_symfony_executable, l:cwd.';')
let l:symfony_root = GetAbsoluteDirname(l:symfony_root)
if strlen(l:symfony_root) != 0
execute 'cd '.l:symfony_root
endif
endfunction
function GetAbsoluteDirname(path)
let l:path = a:path
" gets the dirname
if !isdirectory(l:path)
let l:path = strpart(l:path, 0, strridx(l:path, '/'))
endif
" makes it absolute
if match(l:path, '/') != 0
let l:path = getcwd().'/'.l:path
endif
return l:path
endfunction
note for later: add vimscript support to geshi
Or see the highlighted version on gist.