intellij-idea

IntelliJ: Suppress quote insertion for HTML attributes


In IntelliJ IDEA 11 or 12, with an HTML file open, typing

<img src=

causes automatic insertion of double quotes, resulting in

<img src=""

Since I type ahead of where I read, this usually means I end up with something like

<img src=""image.png" alt="Image"/>"

How do I prevent double-quotes from being inserted automatically after attribute names?


Solution

  • I've tried it with IDEA 12 and double quotes are inserted only after you start completing src attribute and press Enter or type = to confirm the completion. It doesn't happen automatically, you invoke completion that inserts quotes.

    There is no option to control it, so you will have to break your habit to insert quotes manually and use Enter instead.


    It's also possible to use the template completion with:

    imgTab to generate <img src="" alt=""> with the caret inside first pair quotes. Then just enter the image file name, Tab, enter alt text.

    You can always submit a feature request to disable adding quotes on attributes completion.