My Smart Newline script can achieve this. You can examine the code near the top to see how I capture to white space at the start of the line if that's all you care about. I also updated the script this evening to also handle numbered lists, which was part of the original discussion question, though this is a little late for that I suppose, but others might find it useful.
http://www.angelwatt.com/words/2011/04/11/bbedit-smart-newline-open-line/ -Kendall On Mar 26, 4:45 pm, KG <[email protected]> wrote: > Hey Christopher, > > Just a minor request to your existing script. This works fantastically if > you line starts with the bullet. Assuming you have some indentation like 4 > tab stops and then the bullet, the script stops. I made a couple of mods to > the script as follows: > > --------------------------------------------------------------------------------------- > tell application "BBEdit" > try > tell text of front text window > set lineOfInsertionPoint to line (startLine of selection) > set findReco to find "^\\d+\\." searching in > lineOfInsertionPoint options {search mode:grep} > if found of findReco = true then > set leadingNumber to text 1 thru -2 of (found text of > findReco) > set text of selection to return & (leadingNumber + 1) & > ". " > select insertion point after selection > else if found of findReco = false then > set findReco to find "^\\* " searching in > lineOfInsertionPoint options {search mode:grep} > if found of findReco = true then > set text of selection to return & "* " > select insertion point after selection > else > set findReco to find "^\\s*\\+" searching in > lineOfInsertionPoint options {search mode:grep} > if found of findReco = true then > > set text of selection to return & tab & "+ " > select insertion point after selection > end if > end if > end if > end tell > on error errMsg number errNum > set sep to "==============================" > set e to sep & return & "Error: " & errMsg & return & sep & > return ¬ > & "Error Number: " & errNum & return & sep > beep > display dialog e > end try > end tell > --------------------------------------------------------------------------------------- > > Essentially the \s* helps ignore white space at the beginning. There's just > one problem with my script. It inserts the new bullet point ignoring the > previous number of tab stops. Is there a way in applescript to get hold of > the number of tab stops and insert that at the beginning as well? > > Thanks again. > > > > > > > > On Monday, August 8, 2011 7:04:04 AM UTC+3, Christopher Stone wrote: > > > On Aug 07, 2011, at 21:35, oliver wrote: > > > I'm thinking it might have to be an AppleScript to select the line and > > then call a Text Filter to handle finding the number/star and appending the > > next one... but my kung fu is not strong enough to figure it out. > > > ______________________________________________________________________ > > > Hey Oliver, > > > This is very quick and dirty, but it'll work with the numerical increment > > and the asterisk bullet. > > > It's expecting the insertion point (cursor) to be at the end of the line, > > but it could easily be adjusted so that anywhere in the line would do. > > > You can put it in the script menu and give it a keyboard shortcut and go > > to town. > > > The logic is pretty straightforward, so you can add more characters like > > '•' to the mix if desired. > > > -- > > Best Regards, > > Chris > > > ______________________________________________________________________ > > > tell application "BBEdit" > > try > > tell text of front text window > > set lineOfInsertionPoint to line (startLine of selection) > > set findReco to find "^\\d+\\." searching in lineOfInsertionPoint > > options {search mode:grep} > > if found of findReco = true then > > set leadingNumber to text 1 thru -2 of (found text of findReco) > > set text of selection to return & (leadingNumber + 1) & ". " > > select insertion point after selection > > else if found of findReco = false then > > set findReco to find "^\\* " searching in lineOfInsertionPoint > > options {search mode:grep} > > if found of findReco = true then > > set text of selection to return & "* " > > select insertion point after selection > > end if > > end if > > end tell > > on error errMsg number errNum > > set sep to "==============================" > > set e to sep & return & "Error: " & errMsg & return & sep & return ¬ > > & "Error Number: " & errNum & return & sep > > beep > > display dialog e > > end try > > end tell -- You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at <http://groups.google.com/group/bbedit?hl=en> If you have a feature request or would like to report a problem, please email "[email protected]" rather than posting to the group. Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
