How to configure Perl Tidy not wrap the lines?

787 Views Asked by At

I am using Per Tidy plugin in Padre IDE. By default, Tidy wrap my long lines into multiple lines which I don't like. How can I tell Tidy never wrap my lines?

2

There are 2 best solutions below

0
On

You can also change the default settings of perltidy. First find out where it is installed:

perl -MPerl::Tidy -e 'print $INC{"Perl/Tidy.pm"}'

Then edit the file where maximum-line-length is defined (or any other parameters you want). You might need sudo if perltidy is installed gobally. I usually use VS code to format my code and that in turn uses perltidy but I can't define paramters. So I found doing this particularly useful.

1
On

Testing via perltidy on the command-line (referring to the man page), I found that I preferred to change the default perltidy options to always keep newlines (line breaks) by enabling "freeze newlines" (-fnl), and and disabling all whitespace modifications (-fws, freeze whitespace), via options: perltidy -fws -fhl -b

For your specific case, to ignore all line breaks, all you would needs is perltidy -fnl -b (the -b creates a backup file, and modifies in-place.)

There's also a second reasonable option of just setting the line length much longer (for example to 120 chars) than the default of 80 using: -l=120 (or: --maximum-line-length=120 or an even longer "really large number" is enabled by setting it to zero (0).

Note: as an aside, I'm testing on bluefish html editor, which uses either html tidy or perltidy, depending. For some reason, I had to change the rc file directly and couldn't change the setting in the GUI.