I use Change to Column Selection as a quick way of commenting out selected lines. For instance, if I've got a LaTeX selection that looks like this:
%\captionwidth{\textwidth} \begin{comment} \begin{figure} %\includegraphics{table2.pdf}
And I want to comment out the entire selection, then I can't use the Comment Selection command (Command-/) because that simply removes the existing comments. (I think this is a bug in the Source bundle.)
To work around the problem, I can do Change to Column Selection, then hit '%', which achieves the desired effect of commenting out all lines:
%%\captionwidth{\textwidth} %\begin{comment} %\begin{figure} %%\includegraphics{table2.pdf}
However, if I later want to remove the commenting I've added, Change to Column Selection does not work. It seems I am only able to add, not delete, text during column selection. Is this a bug?
Trevor
P.S. The Comment Selection does work properly for removing the comments in the latter case, but it seems wrong to have to use one technique for commenting out a selection and a completely different one for removing the commenting.
On Feb 6, 2006, at 3:56 PM, Trevor Harmon wrote:
And I want to comment out the entire selection, then I can't use the Comment Selection command (Command-/) because that simply removes the existing comments. (I think this is a bug in the Source bundle.)
Not a bug per say. It looks at the first row of the selection to decide whether it should comment or uncomment. How do you expect it to know what to do if half the lines are commented and the other half are uncommented?
However, if I later want to remove the commenting I've added, Change to Column Selection does not work. It seems I am only able to add, not delete, text during column selection. Is this a bug?
Switch to column selection, press shift and right arrow. That selects the first element in each row. Then press delete.
Haris
On Feb 6, 2006, at 2:08 PM, Charilaos Skiadas wrote:
Not a bug per say. It looks at the first row of the selection to decide whether it should comment or uncomment. How do you expect it to know what to do if half the lines are commented and the other half are uncommented?
I was expecting the command to scan the selection for uncommented lines. If there exists at least one uncommented line, then it would know to comment all lines.
On the other hand, I suppose there may be situations where the desired behavior is to remove any commenting that exists. So, the best solution IMHO is to split the command into two: Comment Line and Uncomment Line. After all, I don't see a real benefit for the command to try to guess what I want it to do, especially when it can easily guess wrong. I wouldn't mind an extra command in exchange for the extra accuracy.
Switch to column selection, press shift and right arrow. That selects the first element in each row. Then press delete.
Ah, that works; thanks!
Trevor
On Feb 6, 2006, at 5:51 PM, Trevor Harmon wrote:
On the other hand, I suppose there may be situations where the desired behavior is to remove any commenting that exists. So, the best solution IMHO is to split the command into two: Comment Line and Uncomment Line. After all, I don't see a real benefit for the command to try to guess what I want it to do, especially when it can easily guess wrong. I wouldn't mind an extra command in exchange for the extra accuracy.
I would personally mind the extra shortcut I would need to remember. It is really a toggling thing in my mind, and I use it mainly for big chunks of code that I want to temporarily "turn off". It simply checks the first line in your selection, so if that line is a comment and you want things commented, just start your selection from the first uncommented line instead. Or press it twice.
What you are after instead is an "increase/decrease commenting level" command. That would be a different command, and trivial to implement in most cases.
Haris