Hi Tim,
BBEdit offers plenty of options to manipulate text:
• Scripting with Script Editor or Script Debugger using BBEdit's rich vocabulary of objects and commands:
◦ AppleScript, AppleScriptObjc, JavaScript
• Any executable that can read BBEdit's environment variables:
◦ Interpreted languages: python, perl, javascript, ruby, php, etc;
◦ Shell scripts and command line utilities;
◦ Custom compiled executables.
Which is better depends on the task at hand and your coding preferences.
Here is a sample shell script that reads the environment variables BBEdit's sets up:
#!/usr/bin/env sh
# Name of the document's current language (not set if language is "none")
echo BB_DOC_LANGUAGE $BB_DOC_LANGUAGE ;
# Emacs mode of the document's current language
echo BB_DOC_MODE $BB_DOC_MODE ;
# name of the document
echo BB_DOC_NAME $BB_DOC_NAME ;
# path of the document (not set if doc is unsaved)
echo BB_DOC_PATH "\"$BB_DOC_PATH\"" ;
# (zero-based) end of the selection range (not set if not text document)
echo BB_DOC_SELEND $BB_DOC_SELEND ;
# (one-based) de-tabbed column number of BB_DOC_SELEND
echo BB_DOC_SELEND_COLUMN $BB_DOC_SELEND_COLUMN ;
# (one-based) line number of BB_DOC_SELEND
echo BB_DOC_SELEND_LINE $BB_DOC_SELEND_LINE ;
# (zero-based) start of the selection range (not set if not text document)
echo BB_DOC_SELSTART $BB_DOC_SELSTART ;
# (one-based) de-tabbed column number of BB_DOC_SELSTART
echo BB_DOC_SELSTART_COLUMN $BB_DOC_SELSTART_COLUMN ;
# (one-based) line number of BB_DOC_SELSTART
echo BB_DOC_SELSTART_LINE $BB_DOC_SELSTART_LINE;
# length of the selection
SEL_LENGTH=`expr $BB_DOC_SELEND - $BB_DOC_SELSTART` ;
echo SEL_LENGTH $SEL_LENGTH ;
Scripts should be placed in ~/Library/Application Support/BBEdit/Scripts to appear on BBEdit's Script menu.
HTH,
Jean Jourdain