function! Cdfile()
    cd %:h
    pwd
endfunction

" cd to the root of the current file's git directory
function! Cdroot()
    cd %:h
    exec "cd " . Trim(system("git rev-parse --show-toplevel"))
    pwd
endfunction

function! Cdfile()
    if expand('%') != ''
        cd %:h
    else
        echom "Not currently in a file."
    endif
endfunction

" cd to the root of the current file's git directory
function! Cdroot()
    call Cdfile()
    exec "cd " . Trim(system("git rev-parse --show-toplevel"))
    echom expand('.')
endfunction

Make Cdf and Cdr no-ops when not in a file
Make Cdf and Cdr no-ops when not in a file

yarko3/dotfiles,yarko3/dotfiles