[TxMt] Set soft wrap, justify paragraph, and reformat the last line of paragraph
Allan Odgaard
throw-away-1 at macromates.com
Thu Nov 16 19:03:02 UTC 2006
On 16. Nov 2006, at 19:49, Ulai Beekam wrote:
> I have some text. I know I can use TextMate to do first Soft Wrap
> (and I set the colums to 80). Then, I select the whole text and do
> Reformat Paragraph and Justify.
>
> But after this, I don't want the justification to occur at the last
> line of a paragraph. Therefore, I manually select the last line of
> every paragraph and do Reformat Paragraph on those. Is there a way
> to automate this last process, that is do Reformat Paragraph on all
> last lines of all paragraphs?
You can record the actions as a macro, do a regexp search for (?=\n\n|
\z) to get to the end of last line.
I did one for you (click to install):
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Improved Justify Paragraph.tmMacro
Type: application/octet-stream
Size: 1227 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20061116/67846dbe/attachment.tmMacro>
-------------- next part --------------
> Also: How would I be able to do this without TextMate, i.e. in the
> command line? I'm interested in that because I would like to create
> a PHP script that does exactly this.
From the command line, to collapse whitespace (and newlines) into
one space, and then wrap at the last space before column 80, you
would do:
tr -s '[\n ]' ' '|fold -sw80
To then distribute spaces on all but last line, well, you need to
write some code? :)
More information about the textmate
mailing list