Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Sep 132010

How to set the filetype in Vim


When you created a new file by using the command vi, vim does not know the file type unless you save the file with a specific extension, e.g. test.c, or sometimes when the extension cannot be recognized by vim, you need to set the file type manually in command mode - pressing Esc + :

:set filetype=c

That is it.

  One Response to “How to set the filetype in Vim”

  1. [...] Vim support code formatting and auto indentation - if you tell Vim to know the filetype (either by file extension, or by setting the filetype) [...]

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>