Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

Your Answer

 
discard

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.