[TxMt] Re: TextMate customisation screencast, reflow comment command
Guido Governatori
gvdgdo at gmail.com
Sat Mar 20 08:06:12 UTC 2010
On 20/03/2010, at 9:45 AM, Adam Sharp wrote:
> Hi,
>
> I'm referring to the reflow comment command in this screencast:
> http://blog.macromates.com/2006/customization-screencast/
>
> I have TextMate set to wrap at 72 characters, and currently the command
> is not reflowing this text correctly:
>
By default fmt wrap at 72 characters, and if you followed the screencast, then you should know that you first use fmt to wrap lines, and then you add the comment a bullet characters, so it is 72 + 3. Thus you have to instruct fmt to wrap at 69 characters.
> #!/usr/bin/env ruby
>
> txt = STDIN.read.gsub(%r{\A/|\*/\z}, '')
> txt = txt.gsub(/^[ \t]*\*[ \t]*/, '')
> txt = %x{ fmt <<< '#{txt.gsub(/'/, "'\\\\''")}' }.chomp
change the above line to
> txt = %x{ fmt -69 <<< '#{txt.gsub(/'/, "'\\\\''")}' }.chomp
All the best
Guido
--
Guido Governatori
http://www.governatori.net/Textmate
More information about the textmate
mailing list