Text macros in BBEdit

2,026 views
Skip to first unread message

efaro

unread,
Feb 27, 2009, 5:31:07 AM2/27/09
to BBEdit Talk
Hi everybody,
I would like to define a macro in BBEdit so that by hitting some key
combination BBEdit puts curly brackets around a selected text. Is this
possible?

Thanks for your help.
Emilio Faro

Patrick James

unread,
Feb 27, 2009, 8:42:12 AM2/27/09
to bbe...@googlegroups.com
Hi

Yes of course it is possible :)

Create a new clipping with this content:

{#SELECT#}

Now open the clippings palette and assign keyboard shortcut.


Patrick

http://www.patrickjames.co.uk

efaro

unread,
Feb 28, 2009, 7:36:26 AM2/28/09
to BBEdit Talk
Thank you Patrick!
You just introduced me to the wonderful world of Clipping in BBEdit.
Just what I needed!
Do you know of any ready-made package of clippings for TeX?
Emilio

Maarten Sneep

unread,
Feb 28, 2009, 10:02:15 AM2/28/09
to bbe...@googlegroups.com
On 28 feb 2009, at 13:36, efaro wrote:

> Do you know of any ready-made package of clippings for TeX?

There is one for LaTeX, but in my opinion it is too large. Many of the
item are repeated, and depend on the name of the folder they are in to
make sense of them. This is a problem, because the clippings are also
used in your autocompletion. In the end I removed the clippings set,
because the suggestion I got never was what I intended.

If you feel you want to investigate clippings further, you could do
worse than start with the library Bare Bones has:
http://www.barebones.com/support/bbedit/clippings_library.html

Best,

Maarten

efaro

unread,
Feb 28, 2009, 6:40:14 PM2/28/09
to BBEdit Talk

On Feb 28, 4:02 pm, Maarten Sneep <maarten.sn...@xs4all.nl> wrote:
>
> If you feel you want to investigate clippings further, you could do  
> worse than start with the library Bare Bones has:
>      http://www.barebones.com/support/bbedit/clippings_library.html
>

Thank you Maarten. I think I will take a look at the LaTeX Clippings
and try to pick a few useful ones.

Emilio

outis

unread,
Mar 1, 2009, 7:32:11 AM3/1/09
to BBEdit Talk
Hey, I just thought I'd throw my two cents in here too. Most of the
conversations here are way over my head. But, I actually like LaTeX
clippings library. It's large and unwieldy. But I just make keyboard
shortcuts for the ones I use the most. And for others that I can't
seem to make good shortcuts for, I just add new clipping entries under
the "my Favorites" section.

Though, now that the other guy mentioned it, there are some parts of
that library that I will probably never use. It might be good for me
to throw some of those away.

Bill Hernandez

unread,
Mar 1, 2009, 11:15:36 AM3/1/09
to bbe...@googlegroups.com

On Feb 27, 2009, at 4:31 AM, efaro wrote:

> Hi everybody,
> I would like to define a macro in BBEdit so that by hitting some key
> combination BBEdit puts curly brackets around a selected text. Is this
> possible?

efaro,

I see this has been answered already, so I will share a small example
of clippings usefulness.

Make sure before you call it, or insert it, that the new document has
been saved, so things like #FILENAME# will work correctly.

This is a little header that I use for support pages, and shows some
useful things a clipping will provide.

<?php
$filename = "#FILENAME#" ; // Version
[ #yearnum#_#monthnum#_#monthdaynum# ]
// +---------+---------+---------+---------+---------+---------
+---------+---------+
// define("BH_#BASENAME#", "#BASENAME#", true) ; // uncomment if needed
// +---------+---------+---------+---------+---------+---------
+---------+---------+
/*
CALLED - require_once ("#FILENAME#") ;

Author : #USERNAME#
Created : #creationdate# : (#creationtime#)

Updated by : #USERNAME# - [#monthnum#/#monthdaynum#/#yearnum#](#time#)

Description : #selstart#INSERT_CONTENT_DESCRIPTION_HERE#selend#
*/
// +---------+---------+---------+---------+---------+---------
+---------+---------+
// [1945] ( BEGIN ) BH_SUPPORT_PAGE (section [1945] is used by
support pages only)
// +---------+---------+---------+---------+---------+---------
+---------+---------+
// These arrays have already been initialized in (section [1944])
$aPage['basename'] = "#BASENAME#" ;
// +---------+---------+---------+---------+---------+---------
+---------+---------+
$debug_message = "" ;
$loading_message = "" ;
// +---------+---------+---------+---------+---------+---------
+---------+---------+
$N = ($aLoaded['file_counter'] += 1) ;
$aLoaded[$N] = $aPage['basename'] ;
if ($debug_message != "") { $aDebug[$N] = "[" . $aPage['basename'] .
"]" . $debug_message ; }
if ($loading_message != "") { $aMessages[$N] = "[" .
$aPage['basename'] . "]" . $loading_message ; }
// +---------+---------+---------+---------+---------+---------
+---------+---------+
// [1945] ( _END_ ) BH_SUPPORT_PAGE (section [1945] is used by
support pages only)
// +---------+---------+---------+---------+---------+---------
+---------+---------+
?>

Bill Hernandez

unread,
Mar 1, 2009, 11:51:30 AM3/1/09
to bbe...@googlegroups.com

Bill Hernandez

unread,
Mar 2, 2009, 1:36:00 PM3/2/09
to bbe...@googlegroups.com

On Mar 2, 2009, at 9:43 AM, efaro wrote:

> On Mar 1, 5:15 pm, Bill Hernandez <m...@mac-specialist.com> wrote:
>>
>> Make sure before you call it, or insert it, that the new document has
>> been saved, so things like #FILENAME# will work correctly.
>>
>> This is a little header that I use for support pages, and shows some
>> useful things a clipping will provide.
>>
>

> Thanks Bill. It looks like a nice clip. Could you tell me how to use
> it? I have no idea.

See the instructions after the code block

-------- CLIPPING START ------------


<?php
$filename = "#FILENAME#" ; // Version
[ #yearnum#_#monthnum#_#monthdaynum# ]
// +---------+---------+---------+---------+---------+---------+

// define("BH_#BASENAME#", "#BASENAME#", true) ;

// uncomment previous line if needed
// +---------+---------+---------+---------+---------+---------+


/*
CALLED - require_once ("#FILENAME#") ;

Author : #USERNAME#
Created : #creationdate# : (#creationtime#)

Updated by : #USERNAME# - [#monthnum#/#monthdaynum#/#yearnum#]
(#time#)

Description : #selstart#INSERT_CONTENT_DESCRIPTION_HERE#selend#
*/
// +---------+---------+---------+---------+---------+---------+

// [1945] ( BEGIN ) BH_SUPPORT_PAGE

// section [1945] is used by support pages only
// +---------+---------+---------+---------+---------+---------+


// These arrays have already been initialized in (section [1944])
$aPage['basename'] = "#BASENAME#" ;
// +---------+---------+---------+---------+---------+---------+

$debug_message = "" ;
$loading_message = "" ;
// +---------+---------+---------+---------+---------+---------+

$N = ($aLoaded['file_counter'] += 1) ;
$aLoaded[$N] = $aPage['basename'] ;
if ($debug_message != "") { $aDebug[$N] = "[" . $aPage['basename'] .
"]" . $debug_message ; }
if ($loading_message != "") { $aMessages[$N] = "[" .
$aPage['basename'] . "]" . $loading_message ; }
// +---------+---------+---------+---------+---------+---------+

// [1945] ( _END_ ) BH_SUPPORT_PAGE

// section [1945] is used by support pages only
// +---------+---------+---------+---------+---------+---------+
?>
-------- CLIPPING END ------------

DUE to the wordwrap problems with google note that the following five
lines should all on one line each :

// Version [ #yearnum#_#monthnum#_#monthdaynum# ]

Updated by : #USERNAME# - [#monthnum#/#monthdaynum#/#yearnum#] (#time#)

Description : #selstart#INSERT_CONTENT_DESCRIPTION_HERE#selend#

if ($debug_message != "") { $aDebug[$N] = "[" . $aPage['basename'] .
"]" . $debug_message ; }

if ($loading_message != "") { $aMessages[$N] = "[" .
$aPage['basename'] . "]" . $loading_message ; }


-------- CLIPPING INSTRUCTIONS BEGIN ------------

( 1 ) Copy the next line :

~/Library/Application Support/BBEdit/Clippings


( 2 ) Switch to the 'FINDER' then select :
---> MenuBar -> Go -> Go to Folder... (Shift-Cmd-G)

In the dialog do a
---> Paste (Cmd-V) and hit return

When the finder window opens do
---> (Cmd-N) to create a new folder
---> Name the folder "test", or whatever you want

( 4 ) Switch to the eMail client
Copy the "Clipping text" from the eMail

( 3 ) Launch BBEdit
---> (Cmd-N) to Create New Empty Page
OR
---> MenuBar -> File -> New -> Text Document (Cmd-N)

In the new BBEdit text document window
---> Paste the text from the eMail
---> do a (Cmd-S) to save the document

When the "Save Dialog" appears
---> drag the "test" folder from the finder onto the "Save Dialog"

The previous step will set the "test" directory in the "Save Dialog"
without having to naviagate to it, now you can name the file to
whatever you want, something like "php_header.txt"

Now Select :
---> MenuBar -> Window -> Palettes -> Clippings

And at the top of the "Clippings" window
Select "test" category (folder) from the popup menu

You should see the clipping.

---> (Cmd-N) to Create New Empty Page
---> (Cmd-S) to "SAVE IT" so the clipping will work correctly.

Select the "php_header.txt" clipping and click on the "Insert" button

You should see clipping with all the updated tags on your new page...

If you want to modify any clipping, just select it and hold the
(OPTION) key down, you will notice that the "Insert" button changes to
"Edit", click on it, and the Clipping will be opened for you to edit.
Make any changes you want, save it, and the next time you use it, your
changes will be reflected.

If you want to create another clipping in any particular category, the
easiest way to do it is to select any clipping within the category
folder where you want the new clipping to appear, hold the (OPTION)
key down, click on the "Edit" button and pull up the clipping.

NOW, with the clipping page displayed, click on the "Reveal in Finder"
icon (the one that looks like a document, at the upper left corner of
the page) to take you to that folder at the "Finder" level.

Once you are at the "Finder" level you can do a (Cmd-D) to duplicate
the file, rename the new duplicate, edit it, and when you close it,
and re-select the "Clipping Category", the new clipping will be there
for you to use.

You can create subfolders to simulate subcategories.

My Clippings folder contains a folder for each below. Most folders
have several to many subfolders (subcategories). I have shown an
example of the subcategories for the "PHP.Mine" folder:

Applescript
BASH
CSS
HTML
JavaScript
PHP.Base
PHP.Mine
Align
Begin and End Tags
Block Elements
Comments
Debug Statements
Font
Frames
Globals Redefine
Head Elements
Image
Includes
Pages
Span
Tables
Terminal
URL Link
PropertyLists
test
Universal Items

-------- CLIPPING INSTRUCTIONS END ------------

Hope this helped...

Best Regards,

Bill Hernandez
Plano, Texas

Bill Hernandez

unread,
Mar 2, 2009, 3:17:14 PM3/2/09
to bbe...@googlegroups.com
On Mar 2, 2009, at 1:20 PM, Emilio Faro wrote:

Thank you very much, Bill.

Your profuse explanation has helped me to learn several interesting
tricks on the Mac. I followed your instructions and things seem to
work. I placed the cursor at the top of a file called "cambios" and
upon selecting "php_header,txt" I got the following inserted at the
top of my file:

<?php
$filename = "#FILENAME#" ; // Version
[ #yearnum#_#monthnum#_#monthdaynum# ]
// +---------+---------+---------+---------+---------+---------

+---------+---------+
// define("BH_cambios", "cambios", true) ; // uncomment if needed
// +---------+---------+---------+---------+---------+---------
+---------+---------+


/*
CALLED - require_once ("#FILENAME#") ;
Author : #USERNAME#
Created : #creationdate# :
(#creationtime#)
Updated by : #USERNAME# - [#monthnum#/#monthdaynum#/

#yearnum#](19:48)
Description : INSERT_CONTENT_DESCRIPTION_HERE
*/
// +---------+---------+---------+---------+---------+---------
+---------+---------+
// [1945] ( BEGIN ) BH_SUPPORT_PAGE (section [1945] is used by
support pages only)
// +---------+---------+---------+---------+---------+---------

+---------+---------+
// These arrays have already been initialized in (section [1944])

$aPage['basename'] = "cambios" ;
// +---------+---------+---------+---------+---------+---------

+---------+---------+
$debug_message = "" ;
$loading_message = "" ;
// +---------+---------+---------+---------+---------+---------
+---------+---------+
$N = ($aLoaded['file_counter'] += 1) ;
$aLoaded[$N] = $aPage['basename'] ;
if ($debug_message != "") { $aDebug[$N] = "[" .
$aPage['basename'] . "]" . $debug_message ; }
if ($loading_message != "") { $aMessages[$N] = "[" .
$aPage['basename'] . "]" . $loading_message ; }
// +---------+---------+---------+---------+---------+---------
+---------+---------+

// [1945] ( _END_ ) BH_SUPPORT_PAGE (section [1945] is used by
support pages only)
// +---------+---------+---------+---------+---------+---------
+---------+---------+
?>

with the words "INSERT_CONTENT_DESCRIPTION_HERE" selected.
I can see that the file name "cambios" has substituted the tag
#BASENAME#. The other tags were not substituted; I suppose that this
was due to my not having defined the corresponding parameters of the
file in question.

Since I am not a php programmer I do not know the use of the
particular template of your clipping, but I see that a modified
version of it could be useful in my LaTeX documents.

Thaks a lot again.

Best,
Emilio Faro
Vigo, Spain


If you do :

MenuBar -> Markup -> Update -> Document (Cmd-Ctrl-U)

Will update all the tags automatically. You don't have to define any
of them. They are part of BBEdit...

Bill Hernandez
Plano, Texas


Bill Hernandez

unread,
Mar 2, 2009, 7:58:09 PM3/2/09
to bbe...@googlegroups.com

On Mar 2, 2009, at 1:20 PM, Emilio Faro wrote:

Thank you very much, Bill.

Your profuse explanation has helped me to learn several interesting
tricks on the Mac. I followed your instructions and things seem to
work. I placed the cursor at the top of a file called "cambios" and
upon selecting "php_header,txt" I got the following inserted at the
top of my file:

<?php
$filename = "#FILENAME#" ; // Version
[ #yearnum#_#monthnum#_#monthdaynum# ]
// +---------+---------+---------+---------+---------+---------
+---------+---------+
// define("BH_cambios", "cambios", true) ; // uncomment if needed
// +---------+---------+---------+---------+---------+---------
+---------+---------+
/*
CALLED - require_once ("#FILENAME#") ;
Author : #USERNAME#
Created : #creationdate# :
(#creationtime#)
Updated by : #USERNAME# - [#monthnum#/#monthdaynum#/
#yearnum#](19:48)
Description : INSERT_CONTENT_DESCRIPTION_HERE
*/
// +---------+---------+---------+---------+---------+---------
+---------+---------+
// [1945] ( BEGIN ) BH_SUPPORT_PAGE (section [1945] is used by
support pages only)
// +---------+---------+---------+---------+---------+---------
+---------+---------+
// These arrays have already been initialized in (section [1944])
$aPage['basename'] = "cambios" ;
// +---------+---------+---------+---------+---------+---------
+---------+---------+
$debug_message = "" ;
$loading_message = "" ;
// +---------+---------+---------+---------+---------+---------
+---------+---------+
$N = ($aLoaded['file_counter'] += 1) ;
$aLoaded[$N] = $aPage['basename'] ;
if ($debug_message != "") { $aDebug[$N] = "[" .
$aPage['basename'] . "]" . $debug_message ; }
if ($loading_message != "") { $aMessages[$N] = "[" .
$aPage['basename'] . "]" . $loading_message ; }
// +---------+---------+---------+---------+---------+---------
+---------+---------+
// [1945] ( _END_ ) BH_SUPPORT_PAGE (section [1945] is used by
support pages only)
// +---------+---------+---------+---------+---------+---------
+---------+---------+
?>

Reply all
Reply to author
Forward
0 new messages