Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Prevent line split for keywords in perltidy

by rodd (Scribe)
on Nov 08, 2018 at 15:16 UTC ( [id://1225421]=perlquestion: print w/replies, xml ) Need Help??

rodd has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I'm trying to figure out how to prevent perltidy from splitting lines on certain keywords I may introduce, such as "has" (Moose) etc.

I'd like to avoid perltidy from breaking lines such as:

has arg => qw(is rw isa ArrayRef), default => sub { [] }; # untidy

Into this:

has arg => qw(is rw isa ArrayRef), default => sub { [] }; # nooooooo

I'd just prefer it like this:

has arg => qw(is rw isa ArrayRef), default => sub { [] }; # much better, although I don't mind the indentation # the crucial thing is the "has arg" part

Replies are listed 'Best First'.
Re: Prevent line split for keywords in perltidy
by beech (Parson) on Nov 09, 2018 at 03:34 UTC

    Hi

    Try -boc, --break-at-old-comma-breakpoints

    $ cat 2 has arg => qw(is rw isa ArrayRef), arg => qw(is rw isa ArrayRef), defa +ult => sub { [] }; $ perltidy < 2 has arg => qw(is rw isa ArrayRef), arg => qw(is rw isa ArrayRef), default => sub { [] }; $ perltidy -boc < 2 has arg => qw(is rw isa ArrayRef), arg => qw(is rw isa ArrayRef), default => sub { [] };

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1225421]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-24 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found