Unless I’m using Objective-C, which is fantastically self-documenting, I often like to add comments to parameters to remind me of what they do. For example:
imagecopy($image, $frame, ($x=max($width-$this->topRightCap[kCapWidth], $this->topLeftCap[kCapWidth])), // Destination x 0, // Destination y $x, // Source x 0, // Source y min($this->topRightCap[kCapWidth], $width-$this->topLeftCap[kCapWidth]), // Source width $this->topRightCap[kCapHeight]); // Source height |
The only thing is, it looks terrible and is very hard to read. I usually carefully insert spaces before the comments so they line up, but that’s really hard to maintain.
I use [Textmate](http://macromates.com/), and found an ‘Align Assignments’ script by Chris Poirier which applies very nice formatting to a block of assignments.
Some trivial modifications resulted in a similar script to align comments. Hit Ctrl-Option-Command-/, and:
imagecopy($image, $frame, ($x=max($width-$this->topRightCap[kCapWidth], $this->topLeftCap[kCapWidth])), // Destination x 0, // Destination y $x, // Source x 0, // Source y min($this->topRightCap[kCapWidth], $width-$this->topLeftCap[kCapWidth]), // Source width $this->topRightCap[kCapHeight]); // Source height |
Here it is:
bak hacito sana neler anlatacagim ama once onayla?
I’ve been trying my best to modify your code, but I can’t get it to do what I want.
I want it behave as is, but not to touch lines where the first character is a comment.
So:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tMin = -1/10; tMax = 1/10;
fsa = 200; % sampling rate ts = 1/fs; % sampling period t = tMin:ts:tMax-ts; % sampling duration N = length(t); % number of samples
Becomes:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tMin = -1/10; tMax = 1/10;
fsa = 200; % sampling rate ts = 1/fs; % sampling period t = tMin:ts:tMax-ts; % sampling duration N = length(t); % number of samples
Any tips?
Oops. It didn’t format as planned. But I hope you get the idea.