Beautiful perl formatCodeIt is not only pleasing to the eye, but also easy to read.
Perltidy is a small project of SourceForge. After we finish writing the messy code, he can organize the code like magic. Come and try it !!!
Perltidy home: http://perltidy.sourceforge.net/perltidy.html
Installation Method:
Enter the decompressed directory and run the following command:
Perl makefile. pl
Make
Make Test
Make install
Usage:
Configure Vim so that when writing code, we can beautify our code without leaving vim.
Add the following in the last line of/etc/vimrc: (the shortcut key PT is used to call perltidy)
Map, PT: %! Perltidy
After writing the Perl code, enter the ", PT" command in VIM command mode to directly organize the code format.
Note:
1) if you need to install it in your home directory, as shown below:
Perl makefile. pl prefix = ~ /Perl
Setenv perl5lib ~ /Perl/lib/site_perl/5.8.3
2) use config during the call. The default value is. perltidyrc in the home directory:
By default, perltidy yourscript will generate the yourscript. TDY file. You need to manually overwrite the original file with the TDY file.
If you only use the specified configuration file perltidy-Pro = tidyconfigfile yourscript> yourscript. TDY, then overwrite the original file with the TDY file.
Default configuration file instance. perltidyrc file:
# This is a simple of A. perltidyrc configuration file
# This implements a highly spaced Style
-BL # braces on New Lines
-Pt = 0 # Parens not tight at all
-Bt = 0 # braces not tight
-SBT = 0 # square brackets not tight
My configuration file:
-GNU # GNU coding standards
-Pbp # -- Perl-best-practices
-I = 2 # Use 2 columns per indentation level
-Ci = 2 # continuation indentation is extra indentation spaces applied when a long line is broken.
-Ce # else and elsif are follow immediately after the curly brace closing the previous block
-NBL # places an Opening brace on the same line as the keyword introducing it.
-Bt = 2 # braces not tight
-SBT = 2 # square brackets not tight
-Pt = 2 # tightness of curly braces, Parentheses, and square brackets.
-Nsfs # -- space-for-semicolon
-Native K = s # -- nospace-after-keyword = s removes keywords.
-DWS # -- delete-old-whitespace
Complete!