[TxMt] Reformat Paragraph and Space at the End of a Sentence

Allan Odgaard throw-away-1 at macromates.com
Fri Jul 7 17:28:35 UTC 2006


On 7/7/2006, at 4:50, Di Xiao wrote:

> I just start using Textmate and find the Reformat Paragraph command a
> little bit confusing.  When editing a text file, I usually leave two
> spaces at the end of a sentence, but after "Reformat Paragraph" it
> will leave only one space.

It leaves one spaces? For me it removes them all. It really is a  
“squeeze successive whitespace and newlines into one space, word wrap  
this, and strip leading/trailing space” -- though some exceptions for  
when the paragraph looks like a bullet item, or when it’s indented,  
or when there is a column selection…

> Since I've used emacs for quite a long time, it's natural to compare
> with the fill-paragraph command in emacs.  The behavior in emacs is
> (1) if there is one space after a sentence, fill-paragraph will do
> nothing; (2) if there is more than one space, fill-paragraph will
> change it to two spaces.

What is the point of these trailing spaces?

> Is there a way to change the behavior of "Reformat Paragraph" to match
> fill-paragraph in emacs?

No -- it is however possible to override it. Create a new command  
with input set to “Selection or Scope” and scope selector to  
“meta.paragraph” -- then the command gets the current paragraph (in  
plain text documents) as input (stdin) and can reformat it however it  
wants.

Here’s a simple example (click to install):

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Reformat Paragraph.tmCommand
Type: application/octet-stream
Size: 1055 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20060707/3102c4e4/attachment.tmCommand>
-------------- next part --------------

> I searched the mail archive and find there was a discussion on
> Reformat Paragraph in LaTeX mode.  I agree that the current
> implementation of Reformat Paragraph is completely useless when math
> mode or other enviroment is inside a paragraph.  Is anything going to
> change for that?

If so, it will happen through a scope specific override (placed in  
the LaTeX bundle) using the same approach as outlined above.

Currently though no-one is working on it.




More information about the textmate mailing list