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 (
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
When editing a file from the
$HOME/.bin directory, the
sh filetype is not assigned.
What I am doing wrong here?
~/.bin directory is a symbolic link (see below) but I don't think this might be causing this
$ test -h ~/.bin && echo $? 0