NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Comment code


Joined: 12 Jan 2008
Posts: 12
Location: Orlando, FL
Reply with quote
Take the following code -

Code:

function myFunc()
{
    //echo "commented line";
    echo "uncomment line";
}


highlight the function and hit, Ctrl-/, and you get this -

Code:

//function myFunc()
//{
    //echo "commented line";
//    echo "uncomment line";
//}


now highlight the code again, to uncomment, and you get this -

Code:

function myFunc()
{
    echo "commented line";
    echo "uncomment line";
}


The comment should have made the code look like this -

Code:

//function myFunc()
//{
//    //echo "commented line";
//    echo "uncomment line";
//}


And, I'd like to suggest a feature request, where the // are placed at the beginning of text of the line, not just the beginning of line, for example -

Code:

//function myFunc()
//{
    ////echo "commented line";
    //echo "uncomment line";
//}


Thanks.
View user's profileFind all posts by spintzSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
It works this way by design.
If you need to commend a function that already has a few comments in it, please use multiline-coments /* */

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 12 Jan 2008
Posts: 12
Location: Orlando, FL
Reply with quote
Sad

That's not what I wanted to hear. This "solution" is so non-intuitive it's ridiculous. You're own comment command, uses // for comments, but you want all other comments to use /* */. And here's the real kicker. What if I commented out that first echo command uses the Ctrl+/ command. Then highlighted the entire function and again used the Ctrl+/ command? YOUR program is using the //. Aren't you almost saying your program should be using multi-line comments as well?

Terrible answer.
View user's profileFind all posts by spintzSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Did you try Ctrl+Shift+/ shortcut that is assigned for block comment?

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 12 Jan 2008
Posts: 12
Location: Orlando, FL
Reply with quote
Block comments are even worse. PHP cannot handle embedded block comments. For example -

Code:

<?php

$i = 0;
$j = 1;
$k = 2;

?>


highlight the 2nd line and Ctrl+Shift+/

Code:

<?php

$i = 0;
/*$j = 1;
*/$k = 2;

?>


Well, and before we continue, that's just plain ugly, why isn't the */ at the end of the 2nd line?

So anyways, we continue, and highlight all 3 lines and Ctrl+Shift+/

Code:

<?php

/*$i = 0;
/*$j = 1;
*/$k = 2;
*/
?>


And bam, invalid PHP code :

Quote:

Parse error: syntax error, unexpected '*' in C:\Inetpub\wwwroot\test.php on line 6


If you refer to my original post, and implement the solution I propsed the results would be -

Code:

<?php

$i = 0;
$j = 1;
$k = 2;

?>


Code:

<?php

$i = 0;
//$j = 1;
$k = 2;

?>


Code:

<?php

//$i = 0;
////$j = 1;
//$k = 2;

?>


And everything would be just fine!
View user's profileFind all posts by spintzSend private messageVisit poster's website


Joined: 12 Jan 2008
Posts: 12
Location: Orlando, FL
Reply with quote
Been over a week with no response....is the answer still no?
View user's profileFind all posts by spintzSend private messageVisit poster's website
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
Seems they are taking a break @ NuSphere. Has been a while since Dmitri actually replied to any post here... (april 10th).
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 27 Apr 2008
Posts: 2
Reply with quote
I agree that code should look like
Code:

//function myFunc()
//{
//    //echo "commented line";
//    echo "uncomment line";
//}


Personally I find it difficult to read code like
Code:

//function myFunc()
//{
    ////echo "commented line";
    //echo "uncomment line";
//}

This is because when i'm scrolling down a block of code, i'm looking for a break in the comments // so I know where that block of comments ends


dmitri wrote:
It works this way by design.
If you need to commend a function that already has a few comments in it, please use multiline-coments /* */

Do you mean comment out the whole block with multiline comments /* ... */ or just our comments in the block...

Either way,
Why should I have to use multiline comments when all I want to do is comment out a little line. When im doing database work, depending on whether or not im local to the database depends on which line I use
Code:

$config['dbhost'] = '192.168.0.11';
//$config['dbhost'] = 'internal.mywebserver';


And like I said above, doing
Code:

/*
...
some code
...
$config['dbhost'] = '192.168.0.11';
//$config['dbhost'] = 'internal.mywebserver';
...
...
some more code
...
*/

would also be difficult to see where the commented out block begins and ends

There is only one place I use multiline comments, and that is at the start of a file, as a header
Code:

/*
   Author: Postman Pat
   Date: 01/02/2008
   Fuction: This is the page for viewing all the stock we hold
   
   Revision: v1.2
   
   Revision Info: v1.1 - 08/02/2008
             Postman Pat
                  Fixed a bug in the SQL
   Revision Info: v1.2 - 08/02/2008
             Bob the builder
             Added new field for viewing purchase price of stock item
*/

start of code



What I find my self doing now is either adding/deleting the single line comments to the start of each line by hand, or cutting the code out, using a macro in TextPad to add/delete the // and then paste it back again

Atleast this way, I can read the code and it actually gets commented out correctly
View user's profileFind all posts by casperSend private message


Joined: 27 Feb 2013
Posts: 1
Reply with quote
I have to agree, the solution is not thought through. Also try to do this on an keyboard other than English, e.g. German. The / is accessed by SHIFT+7.... When I press CTRL+SHIFT+7 it set a marker (I think it is a marker!?).
Also I do not understand why the command is not visible on the context menu.
AND BTW the Add or Remove Line Comment does NOT remove a line comment (it sets it , but does not remove it) at least in a HTML file

And its 4 years after the first posting!
View user's profileFind all posts by ZuppiSend private message
Comment code
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic