Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

We have a bunch of sql files with no extension on the file name. I'd like to open them as sql files for syntax highlighting, custom indentation depth, etc., but I don't want to have to rename the files to add the extension every time I want to edit them (and let's just say that they have to stay extensionless).

Is this possible?

share|improve this question
up vote 3 down vote accepted

Yes. This is described in :help section usr_06.txt on syntax highlighting.

You can turn syntax highlighting on and set the filetype this way:

:syntax enable
:set filetype=sql
share|improve this answer
    
Is there a way to put this in an rc file and load using -u at vim launch? In my tests it gets overridden by the file type extension's syntax highlighting and only works for files without associated syntax. – Daniel Beck Nov 28 '12 at 19:46

Are they in an identified location? All in one directory? If so, you can do:

autocmd BufRead,BufEnter /path/to/directory/* set ft=sql

Otherwise you'll have to write your own file detection routine.

share|improve this answer
    
In this case they are, and this works very nicely, thanks! – Dean Nov 28 '12 at 22:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .