Speaking of rectangular selections ...
one other thing I find myself doing quite often, is that I write one, let's
say, variable name with a trailing number, copy it down and then, increment the
number. So, after duplicating one line (with a nice little script) I would have
a bunch of duplicate lines like:
variable1
variable1
variable1
variable1
What I really want is this:
variable1
variable2
variable3
variable4
I tried to come up with a Applescript solution to accomplish it. What I have
now is this: I select the '1's in the first block with a rectangular selection.
Then, I invoke a script, that increments that numbers by one. Here it is:
tell application "BBEdit"
set allTargets to selection
set counter to 0
repeat with oneTarget in allTargets
select oneTarget
try
set yeah_tmp to (get (selection as text) + counter)
set selection to yeah_tmp as text
set counter to counter + 1
end try
end repeat
end tell
This works quite well whilst the numbers do not cross a decimal border (9 ->
10, 99 -> 100, etc. - the character count is no longer valid if a former loop
instance adds to the amount of existing characters). While this solution is
good enough for most of my use cases I thought I might share this with the
group and invite more fluent Applescript speakers to improve it.
Maybe this is even easier with Perl, Python & co. but I have no idea how
rectangular selections are behaving when you throw them at one of these from
BBEdit ...
looking forward to your ideas,
Roland
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>