The context
I store all my shell scripts insde the $HOME/.bin
directory. Because of this, I've been looking for a way to set the sh
filetype whenever I open a file located in that directory. So, I've created the following autocommand
$ cat ~/.vim/ftdetect/sh.vim
au BufNewFile,BufRead $HOME/.bin/* setf sh
which is stored inside the ~/.vim/ftdetect/sh.vim
file. I wrote that command because I found the following statements in the vim
help (:h autocmd-patterns
)
2. When there is a '/' in the pattern, Vim checks for a match against both the
short file name (as you typed it) and the full file name (after expanding
it to a full path and resolving symbolic links).
Environment variables can be used in a pattern: >
:autocmd BufRead $VIMRUNTIME/doc/*.txt set expandtab
The problem
When editing a file from the $HOME/.bin
directory, the sh
filetype is not assigned.
The question
What I am doing wrong here?
Additional context
The ~/.bin
directory is a symbolic link (see below) but I don't think this might be causing this
$ test -h ~/.bin && echo $?
0