Hi,
This is a minor issue. The "Add/Remove Comment" or "Block Comments" command (CTRL+') puts or removes a "comment out" character at the very beginning of the selected lines. However, many source code lines have "comment out" characters preceded by spaces. The "Add/Remove Comment" command fails in those lines. Also, when "Add/Remove Comment" adds a "comment out" character, it breaks the indention pattern. Python relies on indention, so RJ TextEd's "code folding" feature stops working in Python source files.
I think that the "Add/Remove Comment" command should put or remove the "comment out" character after the initial spaces or tabs.
Best regards
The "Add/Remove Comment" command should use indention
-
- Posts: 28
- Joined: 08 Jun 2011 17:14
Re: The "Add/Remove Comment" command should use indention
I don't quite understand. Say, I have this piece of code:
When I highlight it all and comment out, I get this:
This is handy, I have visual clue of the commented block, as comment chars are nicely lined up. Do you want it to look like this:
? That would be ugly and IMHO unproductive.
?? I would say it works as expected: adds comment chars.
Code: Select all
if (isset($osSearchPresets['minlength']))
{
// $minlength = $osSearchPresets['minlength'];
$minlength = 5;
}
Code: Select all
// if (isset($osSearchPresets['minlength']))
// {
// // $minlength = $osSearchPresets['minlength'];
// $minlength = 5;
// }
Code: Select all
// if (isset($osSearchPresets['minlength']))
// {
// // $minlength = $osSearchPresets['minlength'];
// $minlength = 5;
//}
dustwalker wrote:However, many source code lines have "comment out" characters preceded by spaces. The "Add/Remove Comment" command fails in those lines.
?? I would say it works as expected: adds comment chars.
I have never seen broken indentation due to "add comment" command. Perhaps it is due to your specific settings (or highlighter you use)?dustwalker wrote:Also, when "Add/Remove Comment" adds a "comment out" character, it breaks the indention pattern.
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus
-
- Posts: 28
- Joined: 08 Jun 2011 17:14
Re: The "Add/Remove Comment" command should use indention
I misunderstood the "Add/Remove Comment" command. I noticed that if I used it several times, it alternated between adding and removing the "comment character". Also, it used the "comment line character", instead of "begin comment block" and "end comment block" characters. So, I assumed that its purpose was to switch individual lines from code to comment, or from comment to code. Thus, in your example, I expected:
I have done a couple of tests and now I realize that it modifies a selection of contiguous lines, depending on the first character of the first line. The command's other name "Block Comment" should have been a pretty big clue.
The style guide for Python code recommends indenting block comments. I, too, prefer comments indented at the level of the code; they seem less disrupting.
My problem with "Add Comment" and "code folding" happens with languages that use indentation to define blocks of code, like Python. For example:
If I click the little square before the function internet_on(), the code folds to:
Which is fine. However, If I put Python's comment character (#) with "Add/Remove Comment", the code is
which folds to:
which is wrong. "return True" and the next two lines belong to the function internet_on(). I tried editing the syntax file for Python, but I could not find an option to correct this problem.
Best Regards
Code: Select all
// if (isset($osSearchPresets['minlength']))
// {
$minlength = $osSearchPresets['minlength'];
// $minlength = 5;
// }
The style guide for Python code recommends indenting block comments. I, too, prefer comments indented at the level of the code; they seem less disrupting.
My problem with "Add Comment" and "code folding" happens with languages that use indentation to define blocks of code, like Python. For example:
Code: Select all
def internet_on(x):
try:
response=urllib.urlopen(x)
#response=urllib2.urlopen(x,timeout=y)
return True
except IOError as err: pass
return False
def other(x,y):
Code: Select all
def internet_on(x) (...)
def other(x,y):
Code: Select all
def internet_on(x):
try:
response=urllib.urlopen(x)
# response=urllib2.urlopen(x,timeout=y)
return True
except IOError as err: pass
return False
def other(x,y):
Code: Select all
def internet_on(x):
# response=urllib2.urlopen(x,timeout=y)
return True
except IOError as err: pass
return False
def other(x,y):
Best Regards
Re: The "Add/Remove Comment" command should use indention
Got it, thank you! So it seems that the "offending factor" (so to say) is Python's highlighter folding scheme.dustwalker wrote: However, If I put Python's comment character (#) with "Add/Remove Comment", the code isCode: Select all
def internet_on(x): try: response=urllib.urlopen(x) # response=urllib2.urlopen(x,timeout=y) return True except IOError as err: pass return False def other(x,y):
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus