BBEdit Scripts
- copy/paste/cut tags
- tag-o-matic
- delete all
- repeat selection w/ #n#
- delete trailing whitespace
- remove \r wrap <p>
- replace <> with <>
- convert to href
- convert lines to LI’s
copy/paste/cut tags
These are by far my most useful bbedit scripts. Back in the dark days before bbedit I used an html editor named pagespinner. It was decent app, and one feature I sorely missed when I switched to bbedit was its’ ability to copy and paste tags. Once you’ve tried them, you’ll never be able to live without them.
what it does
copy tag: When <b style="color:#F00">selected text</b> is selected and you hit command-option-C, <b style="color:#F00"></b> is copied to the clipboard.
paste tag: When <b style="color:#F00"></b> or <b style="color:#F00"> is in the clipboard, and you have new text selected and you hit command-option-P, the tag is pasted around to the selected text to create <b style="color:#F00">new text</b>. This script will also work with </b> on the clipboard, but this will only paste <b>new text</b>. When there is no seleceted text the tag pair is pasted together and the instertion point is moved between the two tags.
cut tag: When <b style="color:#F00">selected text</b> is selected and you hit command-option-X, <b style="color:#F00"></b> is copied to the clipboard, and <b style="color:#F00"> and </b> is removed from the text, leaving only selected text.
tag-o-matic
This script is the perfect companion to the copy/paste/cut tags scripts. Although simple, and semi-clunky looking, it actually works fast and is very useful. Yet another I can’t live without.
what it does
you can start with some selected text or no selection at all, and hit command-T. This will bring up an alert box with a text field, in that field you could type the contents of a beginning tag, like b style="color:#F00". Once you hit return the tag is then pasted around your selection like so, <b style="color:#F00">selected text</b>. In addition, <b style="color:#F00"></b> is copied to the clipboard so that you can paste the tag elsewhere using the paste tag script.
This may seem clunky, but say you select some text, hit command-shift-T, then “b”, then return and wham! you’ve wrapped the selected text with a tag pair. Sure you could use tools or make scripts to generate various tags, but this way there is only one key command to remember, and no extra palettes to deal with or nothing to click. It’s all keyboard input. Simple, easy, rockin!
delete all
This script was originally called “Selection, Delete” and was written by a swell guy named Jeremy Mates. I updated it for bbedit 6, and I added it here since I find it to be very useful.
what it does
When you hit command-F10 this script will delete ALL occurances of the selected text on the page. For obvious reasons this script can be DANGEROUS, but it is also very handy.
repeat selection w/ #n#
This script was originally called “Selection, Repeat…” and was also first written by Jeremy Mates. However I added some some other features to this script that make it even more powerful and handy.
what it does
With some text selected hit command-F12 and this script will promt you to enter a repeat number. Once entered the script will duplicate the selection that many times.
with a repeat # of 4 …
example text will be duplicated as…
example textexample textexample textexample textThe first feature i’ve added is the ability to put a placeholder #n# in your selected text that will then be replaced with a number as the text is duplicated. You can use as many #n# placeholders as you wish.
with a repeat # of 4 …
example text #n# will be duplicated as…
example text 1example text 2example text 3example text 4A recent addition to this script allows you to replace #n#¥¥¥ with a specified starting number. To use this feature, first enter a number, then instead of choosing “Repeat #”, choose “Start #”. Then when prompted enter the repeat number.¥ the starting number can be 0, or even a negative number (ie. -15). The option to enter a starting number will only appear when the selection contains #n#.
with a start # of 3 and a repeat # of 4 …
example text #n# will be duplicated as…
example text 3example text 4example text 5example text 6Another cool addition to this script allows you to define the total number of leading zeros to each incriment. To do this enter the repeat number as a comma deliminated pair of numbers (i.e. 000,4). Where 000 is the total length of numbers you want to use, and 4 is the repeat number. This option will only work when the selection contains #n#, otherwise the 000 will be ingnored.
with a start # of 3 and a repeat # of 000,4 …
example text #n# will be duplicated as…
example text 003example text 004example text 005example text 006delete trailing whitespace
This script was also first written by Jeremy Mates, i’ve simply updated and posted it here since I find it very useful.
what it does
Hit command-F6 and this script will delete all spaces and tabs from the end of each line. It will either do the whole page, or just the selection.
remove \r wrap with P tag
This script is for people like me who detest hard wrapped code and like to keep things like paragraphs and divs on one long ass line. The alternate version that adds the P tag is very useful for quickly formatting copy sent via email or word.
what it does
Hit command-F9 and this script will remove hard breaks and wrap each string of single returns with a P tag.
so it will convert..
blah textmore example textmore blah text more example textexample textto this …
<p>blah text more example text more blah text</p> <p>more example text example text</p>replace tag brackets with < & >
This one is good for working on code documentation pages…like this one =).
what it does
This script simply replaces all, or selected <> with <>.
convert to href
This one isn’t terribly amazing, but it comes in handy.
what it does
Select a url, email address, or anything for that matter and hit command-F11 and http://www.myselection.com will be converted to <a href="http://www.myselection.com">http://www.myselection.com</a>. When an email address (or anything with an @) is used the selection, selection@clankwerks.com, will be converted to <a href="mailto:selection@clankwerks.com">selection@clankwerks.com</a>. Once the link is made the selection will be set between the beginning and end tags so that the text can then be easily edited.
convert lines to LIs
This one is a another simple, but very useful script.
what it does
Hit command-F8 and this script will convert selected lines (will not work without a selection) and will convert each line into an LI and wrap them with an OL or UL tag depending on what you choose in the quick dialog.