At 00:54 -0500 12/08/2011, Christopher Stone wrote:

Script one will operate on the selected variable name OR let you enter a variable name IF no text is selected...

Place the cursor anywhere in a line consisting of "variable1"

This script supposes you want n similar variables with incrementing indices. You fill in n in the dialog and the required lines are created:

variable1
variable2
variable3
variable4

What's more, the same script could be used for far more complicated operations. No need to fill down, no need to spend waste seconds making a rectangular selection. Quick, short and recyclable.


tell application "BBEdit"
  set _currentline to the startLine of the selection
  tell the front document to select line _currentline
  set _s to the contents of line _currentline of the front document
  tell me to set _dd to display dialog "
  Create how many variables in series '" & _s & "'" default answer "4"
  set _n to text returned of _dd
  set _perloutput to do shell script "perl <<'END'
$count = " & _n & ";
$s = qq~" & _s & "~;
$_ = " & _s & ";
/([^\\d]+)(\\d)/i  and ($varname, $n) = ($1,$2);
for (1..$count) {print qq~$varname$_\\n~}
END"
  set the selection to _perloutput
  select insertion point after selection
end tell


--JD

--
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>

Reply via email to