Re: Using a Text Factory to remove white space

2017-02-10 Thread Christopher Stone
On Feb 10, 2017, at 12:36, brian schroeder > wrote:
> That helps a lot.
> Thanks, Chris!


Hey Brian,

You're welcome.

Just for giggles here are a couple of text-filters.

A simple one-liner `sed` script to remove all horizontal whitespace.

#!/usr/bin/env bash
# --
# Auth: Christopher Stone
# dCre: 2017/02/10 17:53
# dMod: 2017/02/10 18:13
# Task: Remove all horizontal whitespace.
# Tags: @Remove, @Horizontal, @Whitespace
# --

sed -E 's![[:blank:]]+!!g'

Another simple `sed` script to remove all horizontal whitespace and blank lines.

#!/usr/bin/env bash
# --
# Auth: Christopher Stone
# dCre: 2017/02/10 17:53
# dMod: 2017/02/10 18:11
# Task: Remove all leading, trailing whitespace and delete blank lines.
# Tags: @Remove, @Leading, @Trailing, @Whitespace, @Delete, @Blank, @Lines
# --

sed -En '
s![[:blank:]]+!!g
/^$/d
p
'

BBEdit text-filters operate on the selection if there is one, otherwise they 
operate on the whole front document.

Text filters are installed here:

~/Library/Application Support/BBEdit/Text Filters/

Text filters are run from:

BBEdit Menu Bar > Text > Apply Text Filter > 

And of course you can give them keyboard shortcuts in BBEdit's Menus & 
Shortcuts preferences.

--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. 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: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: Using a Text Factory to remove white space

2017-02-10 Thread brian schroeder
That helps a lot.

Thanks, Chris!

Thanks, John!

-Brian

On Tuesday, February 7, 2017 at 10:43:29 AM UTC-8, brian schroeder wrote:
>
> Hi.  How could you use a text factory to remove white space?  Thanks.
>
>
> *Change:   *
>
>
>F,sec,   cfm,   vdc
>
>   F,  sec,   cfm
>
>
> *To:*
>
>
> F,sec,cfm,vdc
>
> F,sec,cfm
>
>
>

-- 
This is the BBEdit Talk public discussion group. 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: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: Using a Text Factory to remove white space

2017-02-08 Thread John Muccigrosso
If you really want all white space (tabs, newlines, etc) then use "\s+" as 
the search pattern.

This is such a fast search and replace, I'd probably use the usual dialog 
or write a quick perl or shell script for it.

-- 
This is the BBEdit Talk public discussion group. 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: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: Using a Text Factory to remove white space

2017-02-07 Thread Christopher Stone
On Feb 07, 2017, at 12:29, brian schroeder > wrote:
> Hi.  How could you use a text factory to remove white space?  Thanks.


Hey Brian,

Open a new Text Factory.

Leave the target as (nothing to process)

Select “Replace All”

Select “Options”

Turn on “grep”

Search for:

[[:blank:]]+

Replace with:

Nothing

Save it here:

~/Library/Application Support/BBEdit/Text Filters/

Personally I subcategorize Text Filters like so:

~/Library/Application Support/BBEdit/Text 
Filters/Textfactories/removeHorizontalWhitespace.textfactory

Run the Text Factory from the menu Text > Apply Text Filter > [Your Text 
Factory], or give it a keyboard shortcut in the BBEdit prefs.

Personally I'd rather use AppleScript than a Text Factory, because it's faster 
– and I have more control.

---
# Auth: Christopher Stone
# dCre: 2017/02/07 15:00
# dMod: 2017/02/07 15:33 
# Appl: BBEdit
# Task: General Handler for Find/Replace – operates on selection if exists – 
otherwise the whole document.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Handler, @Find, @Replace, @Document, 
@Selection, @RegEx
---

bbReplaceText("[[:blank:]]+", "")

---
--» HANDLERS
---
on bbReplaceText(findPattern, replacePattern)
   tell application "BBEdit"
  if (contents of the selection) ≠ "" then
 tell front text window's its text of selection
replace findPattern using replacePattern options {search mode:grep, 
case sensitive:false}
 end tell
  else
 tell front text window's its text
replace findPattern using replacePattern options {search mode:grep, 
case sensitive:false, starting at top:true}
 end tell
  end if
   end tell
end bbReplaceText
---

--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. 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: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Using a Text Factory to remove white space

2017-02-07 Thread brian schroeder


Hi.  How could you use a text factory to remove white space?  Thanks.


*Change:   *


   F,sec,   cfm,   vdc

  F,  sec,   cfm


*To:*


F,sec,cfm,vdc

F,sec,cfm


-- 
This is the BBEdit Talk public discussion group. 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: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.