How to put double slashes next to code, and after all tabs? [message #1737273] |
Wed, 06 July 2016 14:53  |
Eclipse User |
|
|
|
In Eclipse IDE (Java and C/C++), pressing CTRL+/ will comment out a line of code, or selected lines of code, by adding // (double slashes) to the very beginning of the line.
I would like to find a way to put // (double slashes) at the position of the first character of a code, instead of placing it at the very beginning of the line.
Does anyone know? Thanks in advance.
Here is an example code used to demonstrate the process.

When commenting out the specified line using CTRL+/, I get this:

This is what I wanted to do:

Notice the // (double slashes) are located at the first character of the line of commented code. That is where I wanted the // (double slashes) to be.
Another bigger example:

Other than manually typing the // (double slashes) out, I wanted to tweak the shortcut, CTRL+/, so that it can put the // (double slashes) at the very first character of the line of codes.
How can I do this? Thanks in advance.
[Updated on: Wed, 06 July 2016 23:07] by Moderator
|
|
|
|
Re: How to put double slashes next to code, and after all tabs? [message #1737585 is a reply to message #1737579] |
Sun, 10 July 2016 16:12   |
Eclipse User |
|
|
|
Frankly, I would think any change from the current behavior would be just an increase in project complexity with little benefit in return. Lots of potential options here (along with potential future maintenance headaches). For example at the beginning of the text on a line versus what you apparently want, that is, placed at the the first block level selected. Plus the current action, of course. How about inserting a #if 0 .. #endif, too but also retain the current mode of operation without having to change any settings?
Defining what should happen if there was an indented comment might be tricky. Currently, it will not toggle unless all lines have // in columns one and two or none at all. Otherwise, it adds //. Which means sections contain previously commented out code must be omitted from the selection (or not) depending on how the user wants them to be treated. Yet another possible option.
Regardless of what is decided, there will always be that one person who wants something different. Like the person who recently didn't want to have to move his hand from the debugger F6 (Step) key to the Continue button when reaching a line of code that will transfer to the exit code because he didn't want the debugger to step into the exit code. The same problem with stepping into any library function without the library source but perhaps that hasn't occurred to him yet.
Currently, you could, using the column mode, draw a line where you want the comment slashes and type "// ". Not any harder than selecting the lines and hitting CTRL+/. Removing them would be simple, too. Just select the "// " in column mode and hit DEL. Doing these gets what you want and and doesn't depend on built-in guesses.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06552 seconds