Comment out xml file fragments in java IDE

It's easy to comment out and uncomment lines of Java code in any Java IDE, using shortcut keys like Ctrl-/ (in Eclipse), or Ctrl-Shift-T (in NetBeans). But I haven't found such features for XML commenting. I have to always manually add <!-- and --> even when editing those XML files inside Eclipse or NetBeans.

Why is it missing in major Java IDEs? Nowadays almost all Java projects have some XML files, like ant build files, deployment descriptors, etc. And both NetBeans and Eclipse have nice XML editing features, including syntax highlighting, element and attribute auto-completion, and element tree view. All these seem to suggest Java IDEs are serious in supporting XML development. One would think commenting/uncommenting is one of the basic requirements. Why can't I select some lines, press Ctrl-/ or Ctrl-Shift-T to comment out them?

Maybe one reason is that XML doesn't allow nested comments. So if my selection already contains XML comments, I can't add an outer comment. But even in this case, the IDE can either issue a waring, or add 2 smaller comments, one before the existing comment and the other after.


Anonymous said...

IDEA comments/uncomments XML for you with CTRL-/ (toggle line-by-line comments) and CTRL-SHIFT-/ (toggle block comments). In fact ANY file type can have associated line and block comment markers that will be applied appropriately whenever CTRL-/ or CTRL-SHIFT-/ is pressed. I often edit Python, SQL and C++ in IDEA so this is very useful.

With nested comments, the quickest way to deal with them is to select the whole area you want to comment (eg with the fantastic CTRL-W) then press CTRL-SHIFT-/ twice. The first strips existing comments, the second press will block comment the whole area. You do lose the original comment region with this approach though.

Pete Carapetyan said...

With the WTP plugins installed, using the xml editor they provide, Eclipse does this easily and I use all the time.

It's the only thing I use the WTP plugin for, actually, but that's more about my lack of skills than the plugin.

gaferoz said...

Perhaps you haven't tried selecting the block of lines and them clicking the right button, then 'Source' and then 'Add Block Comment'...

Mihai Rus said...

Eclipse IDE CTRL + SHIFT + C - toggle comments in xml files

Cindy Dy said...

You made some good points there. I did a search on the matter and found the majority of people will consent with your blog.


andrea chiu said...

I understand that every person has the passion in any aspects or things. If you love something and it came in front of you it completes your day and your mood turns into something you won't expected. I love your work and I want to read more about it. Visit my site if you have time . Thank you.



lee woo said...

Love it! Very interesting topics, I hope the incoming comments and suggestion are equally positive. Thank you for sharing this information that is actually helpful.


Steve Smith said...

Great and Useful Article.

Online Java Training

Java Online Training India

Java Online Course

Java EE course

Java EE training

Best Recommended books for Spring framework

Java Interview Questions

Java Course in Chennai

Java Online Training India

Geetha Devi said...

Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more .java training in chennai

Sherlin Jones said...

The biggest change in Selenium recently has been the inclusion of the WebDriver API. Driving a

browser natively as a user would either locally or on a remote machine using the Selenium Server it

marks a leap forward in terms of browser automation.

Selenium WebDriver fits in the same role as RC did, and has incorporated the original 1.x bindings.

It refers to both the language bindings and the implementations of the individual browser controlling

code. This is commonly referred to as just "WebDriver" or sometimes as Selenium 2.
Selenium Training Institute in Chennai

Selenium Training in Chennai
Selenium Training with placement assistance in Chennai

Jones Sathya said...

When we speak of Selenium, we are actually talking about both its flavours: Selenium WebDriver and Selenium IDE. Both automate browsers in support of web application testing. WebDriver is typically used to create browser-based regression tests, whereas Selenium IDE is most advantageous in creating unit tests, exploratory tests and one-off bug reproduction scripts. There is no need to make further distinctions between the two, however, when discussing Selenium’s advantages and disadvantages.
Selenium Training in Chennai|Selenium Trianing in Velachery

Mahi Raja said...

This is an awesome post.Really very informative and creative contents.This concept is a good way to enhance the knowledge.

Dipanwita said...

I love your blog. java training in chennai

Roger Binny said...

Our digital marketing course in Chennai is targeted at those who are desirous of taking advantage of career opportunities in digital marketing. Marketing professionals who are presently using traditional marketing to meet their business objectives. Start-ups, Entrepreneurs, Business Owners who desire to make use of online media to improve their business goals and objectives.

Digital Marketing Course in Chennai
Digital Marketing Training in Chennai
Online Digital Marketing Training
SEO Training in Chennai

MOUNIKA said...

Thank you for the information.
Sap Hana Online Training
Sap Cs Online Training
Sap Bw On Hana Online Training

eMexo Technologies said...

Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.

Internet Of Things training in electronic city

Bhuvana said...

I accept there are numerous more pleasurable open doors ahead for people that took a gander at your site.we are providing ReactJs training in Chennai.
For more details: ReactJs training in Velachery | ReactJs training in chennai

HACK 7 said...


sasitamil said...

After reading this web site I am very satisfied simply because this site is providing comprehensive knowledge for you to audience.
Thank you to the perform as well as discuss anything incredibly important in my opinion. We loose time waiting for your next article writing in addition to I beg one to get back to pay a visit to our website in

Selenium training in Chennai
Selenium training in Bangalore
Selenium training in Pune
Selenium Online training

lekha mathan said...

Such an excellent and interesting blog, do post like this more with more information, This was very useful, Thank you.
Aviation Academy in Chennai
Air hostess training in Chennai
Airport management courses in Chennai
Ground staff training in Chennai
aviation training in Chennai
cabin crew course in Chennai
diploma in airline and airport management in Chennai
airport ground staff training in Chennai

jvimala said...

Hey, would you mind if I share your blog with my twitter group? There’s a lot of folks that I think would enjoy your content. Please let me know. Thank you.
Java Training in Chennai | J2EE Training in Chennai | Advanced Java Training in Chennai | Core Java Training in Chennai | Java Training institute in Chennai