[TxMt] Lining up code automatically - perl mainly

Andy Armstrong andy at hexten.net
Fri Dec 7 13:25:20 UTC 2007


On 6 Dec 2007, at 22:35, Simon Holroyd wrote:
> I've just started using TM, previously I used emacs. When I typed a  
> perl
> line like:
>
> my $p = Base::Sub->new
>  (id     => 1234,
>   name => "test");
>
> I would only have to hit tab on each new line to move the cursor to  
> below
> the appropriate place on the above line i.e. it auto formatted the  
> code for
> me. TM doesn't seem to do this, which is annoying the hell out of  
> me. Can
> someone help please?


I bind a key to perltidy and forget all about formatting apart from  
that. I use something like this:

dir=`dirname $TM_FILEPATH`
up=''

for i in 1 2 3 4 5 ; do
	try="${dir}${up}/perltidyrc"
	[ -f $try ] && break;
	try="${dir}${up}/.perltidyrc"
	[ -f $try ] && break;
	up="$up/.."
done

if [ -f $try ] ; then
	perltidy -st -q -pro=$try "$TM_FILEPATH"
else
	perltidy -st -q "$TM_FILEPATH"
fi

So that if I'm working on a project that has its own perltidyrc  
or .perltidyrc I use that otherwise my default settings.

-- 
Andy Armstrong, Hexten







More information about the textmate mailing list