Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Prevent line split for keywords in perltidy

by rodd (Beadle)
on Nov 08, 2018 at 15:16 UTC ( #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
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? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2019-11-17 00:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (85 votes). Check out past polls.

    Notices?