Created
January 25, 2019 01:59
-
-
Save hanxi/58c6137b5871b2a4f1c0609ef6e523f7 to your computer and use it in GitHub Desktop.
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
function! SearchRoot() | |
let l:scm_list = ['.root', '.svn', '.git'] | |
for l:item in l:scm_list | |
let l:dirs = finddir(l:item, '.;', -1) | |
if !empty(l:dirs) | |
return fnamemodify(l:dirs[-1].'/../', ':p:h') | |
endif | |
endfor | |
return getcwd() | |
endfunction | |
let g:root_dir = SearchRoot() | |
autocmd BufEnter * exe ':cd '.g:root_dir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment