Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij IDEA using the wrong comment style

I'm using IDEA 12.1.4, and when I try to insert a line/block comment into an HTML file (*.html), it inserts a jinja2 style comment.

E.g.

<div class="form-group">

becomes...

{# <div class="form-group"> #}

I tried manually setting the Template Data Language to HTML, and jinja files should only be recognized when they have an extension of .jinja. Is there some other setting I'm missing?

like image 256
Pakman Avatar asked Mar 13 '14 20:03

Pakman


People also ask

How do I set default comments in IntelliJ?

Add a new commentType /** before a declaration and press Enter . The IDE auto-completes the doc comment for you. For information on how to disable this feature, refer to Disable automatic comments.

How do I correct indentation in IntelliJ?

While in the editor, select the necessary code fragment and press Ctrl+Alt+I . If you need to adjust indentation settings, in the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Code Style. On the appropriate language page, on the Tabs and Indents tab, specify the appropriate indents options and click OK.

How do I enable auto format in IntelliJ?

IntelliJ, Android Studio, and other JetBrains IDEs The plugin will be disabled by default. To enable it in the current project, go to File→Settings... →google-java-format Settings (or IntelliJ IDEA→Preferences... →Other Settings→google-java-format Settings on macOS) and check the Enable google-java-format checkbox.

How do I toggle comments in IntelliJ?

Single-line comments in Java start with two forward slashes ( // ). To quickly add a line comment in IntelliJ IDEA, press ⌘ / on macOS or Ctrl + / on Windows and Linux.


2 Answers

Go here to change template language settings:

File -> Settings -> Project Settings -> Python Template Languages -> Template Language -> %set_appropriate%.

like image 196
Sibirsky Avatar answered Sep 18 '22 16:09

Sibirsky


I think the problem occurred because my project was configured as Flask Project. That added the following configuration to my Project.iml file:

<component name="TemplatesService">
    <option name="TEMPLATE_CONFIGURATION" value="Jinja2" />
    <option name="TEMPLATE_FOLDERS">
        <list>
            <option value="$MODULE_DIR$/project/app/assets/partials" />
        </list>
    </option>
</component>

When I manually deleted this section and closed/reopened the project, I was able to insert HTML comments.

like image 29
Pakman Avatar answered Sep 19 '22 16:09

Pakman