Comments
Here's a mapping to make this easier:
nmap <silent> <Leader>cd :cd %:p:h<CR>
Note the use of :p first expand the % to a full path -- it takes care of the case where you're already in the correct directory. If that happens, %:h expands to an empty string and the :cd command throws an error. %:p:h is safe as it will never send an empty directory into the :cd command.
Note that 'autochdir' can be turned on to automatic
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.