Tips & Tricks

Custom file types in IntelliJ IDEA

IntelliJ IDEA is a great IDE for Java, Groovy, Flex, Python, Ruby and many other languages. The text editor with camel-hump completion, and version control support are so great that it may be hard to switch to another editor which may lack some useful features. So, when a need arises for me to code in a language that’s not listed on the features page, I just teach IDEA some basics about that language, and feel much more comfortable than I would if I was editing a plain text. Luckily, you don’t have to write a plugin for that, it is possible via the GUI.

Assume you want to edit Haskell code in IDEA. You go to IDE Settings | File Types and press the ‘Add‘ button next to the file types list:

This brings a dialog where you can provide some knowledge about Haskell: case sensitivity, brace matching settings, ways of defining comments and keywords. You can have up to four lists of keywords, which will be colored differently in the editor. And, of course, all of them will be auto-completed.

After you are done with this dialog, all that remains is to assign the *.hs extension to the newly created file type:

And enjoy hacking:

Comments below can no longer be edited.

23 Responses to Custom file types in IntelliJ IDEA

  1. Avatar

    Leonidos says:

    September 14, 2010

    Very stricted options. What about hex numvers like 0ABCh (like in asm)?
    What if sets of reserved words depend on context?
    Why not to provide regular expression like syntax for comments, numbers, reserved words, etc?

  2. Avatar

    Slawek Zachcial says:

    September 14, 2010

    Hi JetBrains,

    I love Intellij and that’s the IDE that I use for all the programming work I do.

    Sometimes I need to edit files that are not part of any project – just one-off edit tasks. I’d be so cool to do this in Idea because of its fantastic editing capabilities. But starting IDE for such a small thing is an overkill.

    I’m thinking there would be a market share to capture if you provided a quick startup and memory efficient editor to handle such edits which do not require a full-blown IDE (with project mgmt and all other goodies). It could replace notepads, textpads, ultraedits, E, etc… I believe all the components are already there. It’s probably just a matter of bundling them together in a scaled-down version.

    Just a thought…

    Keep rocking!

  3. Avatar

    Hans says:

    September 14, 2010

    I have to agree with Leonidos. Not much to brag about here 😉 Very very limited capabilities, only works for the most simple of syntaxes. Try using this to highlight markup, ini-files, yaml (I know it’s build in), .htacces, embedded regex, etc, etc. Not a very useful feature in its present incarnation. Why not develop some kind of dsl to do the highlighting? Perhaps something like what vim has?

  4. Avatar

    Natan says:

    September 15, 2010

    Can you also include this in Language Injection? I have for example XQuery or SPARQL but they are usually tied to another file (XML, Java…) so without language injection they are quite useless and unreadable.

  5. Avatar

    Peter Gromov says:

    September 15, 2010

    Hans, Leonidos, I personally would be glad if there was such a DSL. But the development resources are limited, and we don’t generally need it ourselves, so substantial investments into such support are not too likely. If only someone would like to contribute…

    Slawek, this is possible by some hacking in IDEA CE sources, but AFAIK we don’t plan to release an editor separately. Though the plans may always change.

    Natan, that’s a bit hard because the custom file type is a file type and what you inject is a language, and these are different notions. But I agree that would be a good idea. A YouTrack issue please?

  6. Avatar

    Colin Kershaw says:

    January 20, 2011

    Is there a place to share custom file types for IntelliJ? Kind of like your plugin repository… but a file type repository. 🙂

  7. Avatar

    Peter Gromov says:

    January 21, 2011

    Colin, not yet. But feel free to file a feature request.

  8. Avatar

    TIm Hepner says:

    November 17, 2011

    If custom file types were available in the Settings->Inspections dialogue this would be a lot better.

  9. Avatar

    yole says:

    November 18, 2011

    How they could be available? Inspections don’t know anything about custom file types. If you want to provide your own inspections for a file type, you can do so by writing a plugin.

  10. Avatar

    Kevin says:

    July 25, 2012

    I love IDEA and use it for all of my projects. Especially for Javascript it’s an absolutely fantastic editor. But I do a lot of editing in non-standard languages (or even entirely custom grammars). The ability to add a language is crucial, for me, and I find it to be one of the most painful parts of the IDEA experience. Adding a new language is easy, but setting up the keywords is tedious. I frequently deal with upwards of 1000 keywords for a single grammar. I need to be able to supply those keywords in a text area. Doing it one at a time is too painful.

  11. Avatar

    Peter Gromov says:

    July 26, 2012

    Kevin, sounds reasonable. Feature request please?

  12. Avatar

    Toar Schell says:

    October 2, 2012

    I like the idea of simple syntax highlighting..I wish to add gawk/awk to my current project, and I have stumbled upon the idea of just modifiying the perl file type (its editable and has room for keywords. Only the Key words have to be added one at a time. Any chance they can be bulk imported? Is there an xml stored somewhere that can be modified?

  13. Avatar

    Peter Gromov says:

    October 4, 2012

    Toar Shell, there’s an XML in config/filetypes. Please see for the config directory location. File modifications while IDEA is running may not be applied.

  14. Avatar

    Chris says:

    September 19, 2013

    Hi. Nice feature. Any idea what it means if I’m not allowed to insert any comments into a file with my new type? The file type gets recognized ok, the keywords are highlighted, but I can’t comment out code, neither line nor block. The option is greyed out in the menu.


  15. Avatar

    gromopetr says:

    September 25, 2013

    Chris, this sounds strange. Could you please file a YouTrack issue ( and provide screenshots of your file type configuration there?

  16. Avatar

    Brian Takita says:

    May 26, 2014

    I would like to have a custom format for a simple indentation-based files.


  17. Avatar

    Will says:

    June 26, 2014

    how can i write my own file designer to edit my file type instead of language based text editor. Just like an Android UI designer, or configuration designer . How can i do that? really need help

    • Avatar

      Peter Gromov says:

      June 26, 2014

      It’s only achievable via a plugin, and it’s not an easy task. The starting point is implementing com.intellij.openapi.fileEditor.FileEditorProvider.

  18. Avatar

    David Whitworth says:

    July 12, 2018

    Hey, I’m new to Custom Filetypes and so far I like the feature. It’s simple yet useful. One thing I didn’t yet find, though, is automatic indention…

    In this very special case I want to handle *.rpy files with IntelliJ which are scripts used by the Game Engine Ren’Py. The format is fairly straightforward and easy and doesn’t have excessively many keywords for me to hack into my custom filetype. However, whenever I hit the Enter key after a colon, I’d like the next line to be indented. Is something like that possible in the current state? If so, how?

    • Avatar

      Peter Gromov says:

      July 12, 2018

      No, it’s not possible out of the box with custom file types, sorry. You’d have to write a small plugin for that.

      • Avatar

        David Whitworth says:

        July 13, 2018

        Do you think it would be a realistic possible feature, though? I mean, it’d basically be another list just like the keyword lists and after each line that ends with one of the “words” there, the next line’s indention is incremented once. Sounds pretty easy as a concept to me but I have never written a plugin for a JetBrains program so I wouldn’t know how to do it…

        • Avatar

          Peter Gromov says:

          July 14, 2018

          Implementation-wise it indeed seems easy, but UI-wise less so. How to call the setting for these “words”? Would it be a feature useful also outside your case, for someone else, and if yes, which words would there be?

          Anyway, I think filing a feature request at is a good idea, and we can continue the discussion there.

Discover more