Thursday, June 28, 2007

Howto: Disable auto-insertion of HTML end tags in Eclipse

In Eclipse (version 3.2.1), when editing an HTML page, Eclipse automatically completes HTML end tags that you are in the process of typing for you. For example, if you type:


Eclipse will immediately automatically add the rest of the tag -- in this case, td> -- for you, so that you end up with (with the part Eclipse added shown here in italics):


However, after years of typing HTML, I'm accustomed to quickly typing the entire HTML end tag myself without thinking about it. Over the last few days, since I've started to use Eclipse to edit HTML, I've frequently ended up with HTML like the following while I'm typing something out:


Eclipse adds the second td> automatically, but at the same time I'd typed it out myself without pausing to remember the fact that Eclipse is going to add it for me, and I'd end up with some broken HTML that I would have to either stop what I was doing to fix, or remember to go back and fix later. This got quite aggravating by the time it happened to me for about the 30th time. :-)

I started looking for a way to disable the end tag auto-insertion feature. I searched through the Window | Preferences settings in Eclipse, but couldn't find any setting that was responsible for the end tag auto-insertion. I also searched the Web with Google and Usenet with Google Groups, but couldn't come up with any relevant results even after trying several different variations on my search terms.

Finally, I posted my question to the Eclipse newsgroup eclipse.newcomer (free registration required to browse/post). Nitin Dahyabhai kindly responded and provided the solution:

The HTML end tag auto-insert feature is controlled by the "Smart Insert Mode" setting on the Eclipse Edit menu. You can uncheck the setting there to get Eclipse to stop automatically completing HTML end tags.

Having disabled the "Smart Insert Mode" setting, I'm now much happier while typing HTML into the Eclipse editor. Thanks, Nitin!