1

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?

Jirong Hu
  • 2,315
  • 8
  • 40
  • 63
  • 1
    It would help if you could give some example input, expected output, and what you're getting. – Martin Tournoij Mar 09 '16 at 03:43
  • It's not about coding. It's about format of source code in Padre IDE. When I do Tools --> Perl Tidy -> Format Active Document. Tidy will reformat the whole file I am working on to its default settings, which will wrap long lines. Is there a way to change this default settings not doing this wrap? – Jirong Hu Mar 09 '16 at 14:50
  • I don't know why "an example" is required. Configuring line length for wrapping is a rather straight-forward concept -- just hard to find in some tools that wrap other tools that mask how to actually set these underlying options. – michael Dec 11 '17 at 12:09

2 Answers2

1

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.

michael
  • 9,161
  • 2
  • 52
  • 49
  • One additional thought: be sure it's `perltidy` that's actually doing the work, and not another tools like `tidy`, which is also known as "html tidy". In my case, `bluefish` uses both, depending on which menu item is being used. – michael Dec 11 '17 at 12:10
0

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.

Cão
  • 521
  • 5
  • 7