VIM 不检测 .ssh/config 的语法

Eri*_*rik 2 ssh vim syntax-highlighting

vi ~/.ssh/config
  :set syn?
  >syntax=conf
Run Code Online (Sandbox Code Playgroud)

当我做:

set syn=sshconfig
Run Code Online (Sandbox Code Playgroud)

然后语法高亮就是它应该的样子。

为什么不能自动识别文件类型?以及如何自动设置?

mul*_*ine 5

假设您所做的是创建了一个符号链接 '~/.ssh' 到系统上其他位置名为 'ssh' 的文件夹,例如 ~/git/ssh,您有两个选项:

方案一

在 '~/.vim/ftdetect/ssh.vim' 中放置以下行:

au BufNewFile,BufRead */ssh/config  setf sshconfig
Run Code Online (Sandbox Code Playgroud)

方案B

确保符号链接解析到的文件夹名为“.ssh”

罪魁祸首档案?/usr/share/vim/vim73/filetype.vim:

au BufNewFile,BufRead ssh_config,*/.ssh/config  setf sshconfig
Run Code Online (Sandbox Code Playgroud)