function! DottedLCD(filename)
	" ignore netrw filenames
	if a:filename =~ '^[a-z]\+:'
		return
	endif
	let dir=substitute(a:filename,'\(.*\)/./.*$','\1','')
	if dir != a:filename
		exe ":lcd ".dir
	endif
endfun

aug DottedLCD
	au BufReadPost * call DottedLCD(expand("<afile>"))
aug END

function! DottedLCD(filename)
	" Get the arglist value if present, otherwise the passed-in <afile>
	let i = argidx()
	let name = i < 0 ? a:filename : argv(i)

	" ignore netrw filenames
	if name =~ '^[a-z]\+:'
		return
	endif

	" find the '/./' that relativizes the path
	let dot = stridx(name, '/./')
	if dot < 0
		return
	end

	" take everything up to the relativizer
	let dir = strpart(name, 0, dot)
	exe ":lcd ".dir
endfun

aug DottedLCD
	au BufReadPost * call DottedLCD(expand("<afile>"))
aug END

Rework "dotted directory" changing in Vim
Rework "dotted directory" changing in Vim

Rsync has a great `-R` which lets you put a superfluous `/./` in a
source path to make other filenames relative to that point in the path
hierarchy.

I'm not sure whether something changed in Vim, or if I never used it,
but my function for doing a similar thing in Vim was broken: the
filename reported by `expand("<afile>")` no longer contained the `/./`.
Instead, if present, use the arglist version of the current window's
filename.

benizi/dotfiles,benizi/dotfiles,benizi/dotfiles,benizi/dotfiles,benizi/dotfiles,benizi/dotfiles,benizi/dotfiles,benizi/dotfiles