Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
vi ~/.ssh/config
  :set syn?

When I do:

set syn=sshconfig

Then the syntax highlighting is as it should be.

Why isn't the filetype automatically identified? And how can it be set automatically?

share|improve this question
It works correctly for me. What version of Vim do you have? (:version within Vim, or vim --version on the command line) – Heptite Oct 17 '12 at 21:06
VIM - Vi IMproved 7.3 – Erik Oct 17 '12 at 21:13
What does ":verbose set filetype?" (include the question mark as part of the command) show when you have opened .ssh/config in Vim? – Heptite Oct 17 '12 at 21:20
up vote 2 down vote accepted

Assuming what you've done is created a symlink ‘~/.ssh’ to a folder named ‘ssh’ somewhere else on your system, for example ~/git/ssh, you have 2 options:

Solution A

inside ‘~/.vim/ftdetect/ssh.vim’ put the following line:

au BufNewFile,BufRead */ssh/config  setf sshconfig

Solution B

Make sure that the folder which the symlink resolves to is called ‘.ssh’

The culprit file ⇒ /usr/share/vim/vim73/filetype.vim:

au BufNewFile,BufRead ssh_config,*/.ssh/config  setf sshconfig
share|improve this answer

Adding this line to your ~/.vimrc

filetype plugin indent on

should be enough for Vim to recognize the filetype and apply the correct syntax.

share|improve this answer
That line already exists in my .vimrc, the problem is only with the syntax of .ssh/config – Erik Oct 17 '12 at 21:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.