Skip to content

Instantly share code, notes, and snippets.

@h-east
Created December 7, 2018 05:30
Show Gist options
  • Save h-east/c5020bc9be1a70631f0b72b018612558 to your computer and use it in GitHub Desktop.
Save h-east/c5020bc9be1a70631f0b72b018612558 to your computer and use it in GitHub Desktop.
" カレントディレクトリを tagsファイルのあるディレクトリ(==プロジェクトルート)へ移動する
function! s:cdProjectRoot()
let filepath = findfile("tags", ".;")
if filepath != ""
let cd = substitute(filepath, "tags$", "", "")
if cd != ""
exec "cd" cd
echo "Cd to project root(" . cd . ")"
else
echo "Already in project root(" . getcwd() . ")"
endif
else
echo "\"tags\" is not found"
endif
endfunc
command! ProjRoot call s:cdProjectRoot()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment