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:

<td></

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):

<td></td>

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:

<td></td>td>

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!

2 comments:

  1. Hi Jon,

    I found this blog entry via Google when searching for how to disable the auto-insertion of HTML end tags in Eclipse. For those people who also find your entry and can't find the "Smart Insert Mode" setting: this setting is not visible in all Eclipse perspectives. You can use the key combination CTRL + SHIFT + Insert instead to toggle Smart Insert Mode.

    Regards,
    Jeroen

    ReplyDelete
  2. one other problem with 'auto-insertion' of closing tags is that it assumes you're writing in a linear fashion. people often don't write in such a direct way.

    for example you might write a list of items, just plain text, then go back and wrap the content in the correct tags. in such a case, auto insert gets in the way.

    lb (secretGeek.net)

    ReplyDelete

Non-spammers: Thanks for visiting! Please go ahead and leave a comment; I read them all!

Attention SPAMMERS: I review all comments before they get posted, and I REPORT 100% of spam comments to Google as spam! Why not avoid getting your account banned as quickly -- and save us both a little time -- by skipping this comment form and moving on to the next one on your list? Thanks, and I hope you have a great day!