Re: Move to beginning of line after whitespace

2012-06-09 Thread Oliver Taylor
Thanks everyone, these work great!

-- 
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 bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
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 supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit


Re: Move to beginning of line after whitespace

2012-06-04 Thread John Delacour

At 11:46 -0700 3/6/12, Oliver Taylor wrote:


I'm trying to write an applescript that emulates vim's go to first 
non-whitespace character on the line.


I'm also building it to be smart about skipping lists (since most of 
my writing is prose).



Try this:


tell application BBEdit
  set _line to startLine of selection
  tell front document
set _chars to characters of (get contents of line _line)
set _i to 0
repeat with _c in _chars
  set _i to _i + 1
  if _c is not in {space, tab} then
select insertion point before character _i of line _line
exit repeat
  end if
end repeat
  end tell
end tell


JD

--
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 bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
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 supp...@barebones.com rather than posting to the group.

Follow @bbedit on Twitter: http://www.twitter.com/bbedit


Move to beginning of line after whitespace

2012-06-03 Thread Oliver Taylor
I'm trying to write an applescript that emulates vim's go to first 
non-whitespace character on the line.

I'm also building it to be smart about skipping lists (since most of my 
writing is prose).

The problem is that it seems like the find operation triggers before the 
keystroke. Is there a simple way to tell BBEdit to do one at a time and 
wait for the previous to finish before triggering the next?

*tell* *application* BBEdit

*tell* *application* System Events

*keystroke* a using control down

*end* *tell*

*try*

*find* ([^ \\t\\*\\-\\•\\d\\.]) searching in *text* *of* *front* *text 
window* options {search mode:grep, starting at top:false, wrap around:false, 
backwards:false, case sensitive:false, match words:false, extend selection:
false} *with* selecting match

*end* *try*

*end* *tell*

*
*

Thanks!

-- 
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 bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
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 supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit


Re: Move to beginning of line after whitespace

2012-06-03 Thread Christopher Stone
On Jun 03, 2012, at 13:46, Oliver Taylor wrote:
 I'm trying to write an applescript that emulates vim's go to first 
 non-whitespace character on the line.
__

Hey Oliver,

No need for System Events - BBEdit can do it.

--
Best Regards,
Chris


try
tell application BBEdit
tell text of front text window
select insertion point before character 1 of line 
(startLine of selection)
find ([^ \\-\\t\\d*•.]) options {search mode:grep, 
starting at top:false, wrap around:false, backwards:false, case 
sensitive:false, match words:false, extend selection:false} with selecting match
end tell
end tell
on error eMsg number eNum
set {c, s} to {return, --}
set e to s  c  Error:   eMsg  c  s  c  Error Number:   eNum 
 c  s
beep
set dDlg to display dialog e buttons {Cancel, Copy, OK} default 
button OK
if button returned of dDlg = Copy then
set the clipboard to e
end if
end try




-- 
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 bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
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 supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit


Re: Move to beginning of line after whitespace

2012-06-03 Thread Kendall Conrad
I wrote a script a while back based on discussions here that do this, 
though I'm not sure about the behavior you mention about lists. That part 
wasn't clear to me, though I might have an idea. The script goes to the 
first non-whitespace character on first execution. If done a second time 
(or you're already at the first non-white) then it will go to the true 
first position.

http://www.angelwatt.com/words/2010/07/31/bbedit-textwrangler-home-key-behavior/

-Kendall

On Sunday, June 3, 2012 2:46:55 PM UTC-4, Oliver Taylor wrote:

 I'm trying to write an applescript that emulates vim's go to first 
 non-whitespace character on the line.

 I'm also building it to be smart about skipping lists (since most of my 
 writing is prose).

 The problem is that it seems like the find operation triggers before the 
 keystroke. Is there a simple way to tell BBEdit to do one at a time and 
 wait for the previous to finish before triggering the next?

 *tell* *application* BBEdit

 *tell* *application* System Events

 *keystroke* a using control down

 *end* *tell*

 *try*

 *find* ([^ \\t\\*\\-\\•\\d\\.]) searching in *text* *of* *front* *text 
 window* options {search mode:grep, starting at top:false, wrap around:
 false, backwards:false, case sensitive:false, match words:false, extend 
 selection:false} *with* selecting match

 *end* *try*

 *end* *tell*

 *
 *

 Thanks!


-- 
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 bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
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 supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit