Skip to content

Instantly share code, notes, and snippets.

@rwilcox
Forked from jshell/gist:2047480
Created April 3, 2012 00:49
Show Gist options
  • Save rwilcox/2288375 to your computer and use it in GitHub Desktop.
Save rwilcox/2288375 to your computer and use it in GitHub Desktop.
Underline Titles (Markdown, reStructuredText) in BBEdit
-- Thanks to hristopher Stone
tell application "BBEdit"
set textDocument1 to a reference to text of text document 1
tell textDocument1
tell line (startLine of selection)
if startLine > 1 then
set lineContent to contents
if (length of lineContent = 1) and (lineContent is not " ") then
set prevLineContent to contents of textDocument1's line ((startLine) - 1)
tell application "BBEdit" to replace "." using lineContent searchingString prevLineContent options {search mode:grep}
set its contents to result
select insertion point after it
end if
end if
end tell
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment