I am trying to pattern match autocmd to a directory referenced by a symlink. I don't want to refer to the actual directory name in my script as the symlink can change targets.

I have the directory foo/fr and foo/en etc, with a symlink foo/source that points to either fr or en. I want to run:

autocmd BufNew */source/*  CallAFunction()

I only want to run autocmd on en/* or fr/* if it is the 'source'. Typically I would cd into 'source' and create the file there.

But I can see in the vim help/docs that this 'resolves' symlinks so I can't pattern match with that. I thought that maybe fnamemodify might help out here, but it also does the same.

Any suggestions on how to get around this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.