Perl::Tidy is a nice module providing the functionality to automatically format your perl code.
This instruction is done for the Textpad version 5.4.2 , but it should work on all TP > 4.7 versions
1. Install the Perl::Tidy module
1.1. Start the cmd shell
Start - Run - cmd
1.2. Start the cpan shell ( You should have perl in the Windows PATH env variable )
perl -MCPAN -e shell
1.3. install the Perl::Tidy module
install Perl::Tidy
2. Create a new file named perltidy.ini in your perl modules folder
2.1. Start - Run - textpad C:\Temp\projects\MyProject\perltidy.ini
2.2. Set the initial configuration of the Perl::Tidy in the this file copy paste as follows
### START COPY
# Perl Best Practices (plus errata) .perltidyrc / perltidy.ini file
-l=98 # Max line width is 98 cols
-i=3 # Indent level is 3 cols
-ci=3 # Continuation indent is 3 cols
#-st # Output to STDOUT
-se # Errors to STDERR
-vt=2 # Maximal vertical tightness
-cti=1 # No extra indentation for closing brackets
-pt=1 # Medium parenthesis tightness
-bt=1 # Medium brace tightness
-sbt=1 # Medium square bracket tightness
-bbt=1 # Medium block brace tightness
-nsfs # No space before semicolons
-nolq # Don't outdent long quoted strings
-wbb="% + - * / x != == >= <= =~ < > | & **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="
# Break before all operators
# Extras/overrides/deviations from Perl Best Practices
--maximum-line-length=78 # Be less generous
--warning-output # Show warnings
--maximum-consecutive-blank-lines=2 # Default is 1
--nohanging-side-comments # Troublesome for commented out code
-isbc # Block comments may only be indented if they have some space characters before the #
-ci=2 # Continuation indent is 2 cols
# We use version control, so just rewrite the file
-b
# For the up-tight folk
-pt=0 # parenthesis tightness
-bt=0 # brace tightness
-sbt=0 # square bracket tightness
### STOP COPY
3. Configure Textpad
3.1. In Textpad - Configure Preferences - Alt + C , P
3.2. Tools - Add - Dos Command
3.3. Parameters: perl -x -S perltidy $FileName
3.4. Initial Folder : $FileDir
3.5. Check Save all documents first
3.6. Capture output
4. Assign shortcut
4.1. In Textpad - Configure Preferences - Alt + C , P
4.2. Click Keyboard-Tools-Commands
4.3. Choose the perl -x -S perltidy $FileName
4.4. Alt + H or click on the "Press new shortcut " textbox
4.5 Ctrl + 9 for the new shortcut ( or choose your own ; )
4.6. Click Apply
4.7. Click OK
5. Test functionality
5.1. Open my module Start - Run - type textpad C:\Temp\Proejcts\MyProject\MyModule.pm
5.2. Ctrl + 9 to format , the result should be reloaded re-formatted source file
how-to configure the perl tidy to work with textpad on windo
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 41
- Joined: Sat May 20, 2006 9:10 pm
- Location: Helsinki
- Contact: