How to turn off automatic html tag closing

I replied to this in another forum
but possibly that wasn't the proper place to post.

Bottom line is I hate that when I'm editing JSPs, that IDEA automatically completes the closing html tags for me. I can't find a way to turn this off. Considering this has been in place for so long, I'm guessing it doesn't bother that many people? I'm using 5.0.2.

If there is a way to disable this that I'm just missing?


Comment actions Permalink

I found the auto-tag annoying also when they first introduced.

If there is no text to the right of the cursor when you type a , it will insert closing tag . The behavior is a bit strange. For example, if I start typeing out a table on the same line, only the tag will be auto-closed:

What made this less annoying for me is that I come from an Emacs background, so I have CTRL+K bound to "cut to end of line", so if I type: | and IDEA inserts the matching which I don't want: | then I can hit CTRL+K to cut it. Sometime I use it to my advantage. For example, if I have some text I want to format: blah blah blah blah.. blah blah blah. I will add a

or | blah blah blha blah... blah blah blah. and then I CTRL+K cut the and then move it down to the end blah blah blah blah... blah blah blah. ]]>

You can also hit Select Word at Caret twice, and then Cut to do the same. I didn't even know about the CTRLALTJ surround with that Maxim mentioned. I will try to integrate that into my editing because it is even faster. But back to the auto-tag behavior. I've learn to deal with it but it is definately a mixed bag, because sometimes you want it and sometimes you don't. Sometimes I want it even when it won't do it, i.e. when there is text ot the right of the cursor. I would like the option to turn this feature off and instead have a keybinding for 'close tag', so that I can control when IDEA closes the tag. The behavior of 'close tag' should be that it should search backwards from the cursor and find the closest tag, and then search forwards from the cursor to the next tag and then insert the closing tag. If there is a selection, it could search backwards from the selection to find the tag, and then insert the closing tag right after the selection. For example, if I have

start of paragraph some sty|led text

If the cursor is on the word styled, and I invoke 'close tag', then I should get:

start of paragraph some styled text

Something more advanced that IDEA could do which I think would work nicely is to automatically close tags using knowledge of the html dtd, e.g. tag con only contain , , ,, , etc. (See So, I should be able to type an HTML table, and IDEA will automatically insert a closing tag for an open element when I start a new tag which can't be contained by the currently open element,e.g. ,
content of the new td, then IDEA shold close the previous td because td can't contain another td.
content ]]>|

I like features which just happen automatically without having to remember to press CTRLALTJ or whatever. I can't think of any situations where it would do the wrong thing. At least it would seem to do the right thing more often than the current auto-tag insert behavior.

Comment actions Permalink

I've done your approach as well Alex and it's pretty good.

I found a way that seems to work for disabling them though. I just disabled the html "tag pair" live template (unchecked html and jsp).

That seems to do the trick.


Please sign in to leave a comment.