Skip to content

Instantly share code, notes, and snippets.

@saihoooooooo
Created February 8, 2012 05:42
Show Gist options
  • Save saihoooooooo/1765850 to your computer and use it in GitHub Desktop.
Save saihoooooooo/1765850 to your computer and use it in GitHub Desktop.
auto lcd, and toggle command
if !exists('g:auto_lcd')
let g:auto_lcd = 1
endif
autocmd MyAutoCmd BufEnter * if g:auto_lcd | execute "lcd " . expand("%:p:h") | endif
command! -nargs=0 ToggleAutoLcd call <SID>ToggleAutoLcd()
function! s:ToggleAutoLcd()
lcd %:p:h
let g:auto_lcd = !g:auto_lcd
if g:auto_lcd
echo 'set autolcd'
else
echo 'unset autolcd'
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment