Sep 13
When I’m writing iRules programs on my MacBook Pro as part of my job at F5 Networks, I like to copy in configuration and setup information as part of documenting the program. This entails cutting and pasting in multi-line config file sections and then adding the ‘#’ comment character to the start of each line. Well, after doing that a couple of times, I knew there was a way to automate that. Enter some Applescript:
(* Comment/Uncomment Block
Add & remove '# ' in Selection. Good for iRules comments.
Assign to a key for best use.
John Allen, F5 Networks
Sept. 12, 2011
*)
tell application "BBEdit"
activate
repeat with x in lines of selection of window 1 of text document 1
if exists character 1 of text of x then
set start to character 1 of text of x as text
else
set start to ""
end if
if start is not "#" then
replace "^" using "# " searching in text of x options {search mode:grep}
else
replace "^# " using "" searching in text of x options {search mode:grep}
end if
end repeat
end tell
Of course, you can modify this to work with any programming language.






