Setting default language (syntax coloring) for new documents?

1,153 views
Skip to first unread message

David Dierauer

unread,
Jan 6, 2016, 3:36:13 PM1/6/16
to bbe...@googlegroups.com
I have a new co-worker who's impressed with what I've shown her of
BBEdit and is currently trying out TextWrangler. She primarily works
with SQL, and would like to have the default language and syntax
coloring for new documents be SQL (since she frequently pastes
queries into new docs rather than opening existing docs with
easily-mappable extensions). I assumed this would be easy to
achieve, but browsing the prefs and searching the manual have left
me mystified.

Can this be achieved, or is it necessary to manually set the doc
language every time?

--
David Dierauer
Software Engineer
da...@dierauer.net

Patrick Woolsey

unread,
Jan 6, 2016, 3:55:14 PM1/6/16
to bbe...@googlegroups.com
Yes, you can accomplish this by setting an expert prefs option
as follows; cribbing from the "Expert Preferences" page of the
online help (Help -> BBEdit Help):

====
Language Support

* If you like, you can set the default language for new untitled
documents:

[ by issuing the following Terminal command ]

defaults write com.barebones.bbedit
DefaultLanguageNameForNewDocuments -string "<language name>"

where "<language name>" should be the name of a language
shown as
installed in the Language preferences. For example, if you want
all new documents to be Markdown:

defaults write com.barebones.bbedit
DefaultLanguageNameForNewDocuments -string "Markdown"

====

or for example, you can specify the "SQL (Generic)" flavor via:

defaults write com.barebones.bbedit
DefaultLanguageNameForNewDocuments -string "SQL (Generic)"


[PS: TextWrangler also supports this option so you need only
change the bundle identifier in the 'defaults' command to 'com.barebones.textwrangler'.]


Regards,

Patrick Woolsey
==
Bare Bones Software, Inc. <http://www.barebones.com/>

David Dierauer

unread,
Jan 6, 2016, 5:25:08 PM1/6/16
to bbe...@googlegroups.com
Ah, expert prefs! I should have thought to check them. Thanks very much!

-David

Christopher Stone

unread,
Jan 7, 2016, 1:31:42 AM1/7/16
to BBEdit-Talk
On Jan 06, 2016, at 16:25, David Dierauer <d+g...@dierauer.net> wrote:
Ah, expert prefs! I should have thought to check them. Thanks very much!
______________________________________________________________________

Hey David,

Save as a compiled script or script bundle with the Script Editor.app.

Put it in BBEdit's script menu folder.

~/Library/Application Support/BBEdit/Scripts/

Give it a keyboard shortcut like Cmd-Opt-Ctrl-Shift-E, and presto!  (Easy access helps you remember to look.  Safari runs 24/7 on my system, and I prefer it to the “Help” Viewer.)

--
Best Regards,
Chris

-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2015/05/07 01:05
# dMod: 2016/01/07 00:22
# Appl: Finder, Safari
# Task: Open BBEdit's Expert Preferences Help in Safari
# Tags: @Applescript, @Script, @Finder, @Safari, @Open, @Expert, @Preferences
-------------------------------------------------------------------------------------------

tell application "Finder" to set _url to URL of (alias ((path to application id "com.barebones.bbedit" as text) & "Contents:Resources:BBEdit Help:ExpertPreferences.html"))

tell application "Safari"
  activate
  make new document with properties {URL:_url}
end tell

-------------------------------------------------------------------------------------------

Reply all
Reply to author
Forward
0 new messages