Eclipse 內有 Formatter 的功能, 但 EPIC 預設的格式我不太喜歡, 在 perference 內可以設定的選項都不太符合我的需求,查了一下發現他是利用 PerlTidy 來做 formatter.
http://www.epic-ide.org/guide/ch02s04.php
http://stackoverflow.com/questions/3724257/how-to-format-perl-code
以下的安裝除了裝 PerlTidy, 還有裝 Tidyview
之後就可以利用 tidyview 來找出你的要設定, 並且 output 成一個設定檔, 把它放到 /etc/perltidyrc
我的內容長這個樣子, 可以參考看看
其實放到 /etc/perltidyrc 後, EPIC 就會自動讀取這個檔案, 但我發現 EPIC 會主動加上 --maximum-line-length=80, 導致我在設定檔內的設定失效. 所以如果遇到這個狀況, 我的解決方式是在 EPIC 內多加上一個 -l=120,
http://www.epic-ide.org/guide/ch02s04.php
http://stackoverflow.com/questions/3724257/how-to-format-perl-code
PerlTidy
Official site: http://perltidy.sourceforge.net/
Installation
以下的安裝除了裝 PerlTidy, 還有裝 Tidyview
$ sudo apt-get install libx11-dev
$ sudo apt-get install perltidy
$ sudo apt-get install perl-tk
$ sudo cpan install Tk
$ sudo cpan install TK::DiffText
$ wget http://prdownloads.sourceforge.net/perltidy/perltidy_20121207-1_all.deb
$ sudo dpkg -i perltidy_20121207-1_all.deb
$ wget http://sourceforge.net/projects/tidyview/files/latest/download -O tidyview.tar.gz
$ tar xzvf tidyview.tar.gz
$ cd tidyview*
$ cat README
To install this module, run the following commands:
perl Makefile.PL
make
make test
make install
DEPENDENCIES
Tk
Log::Log4perl
perltidy
$ perl Makefile.PL
$ make
$ make install
/etc/perltidyrc
之後就可以利用 tidyview 來找出你的要設定, 並且 output 成一個設定檔, 把它放到 /etc/perltidyrc
我的內容長這個樣子, 可以參考看看
# ON-OFF style options --break-after-all-operators --no-break-before-all-operators --no-closing-side-comments --cuddled-else --no-ignore-side-comment-lengths --no-indent-closing-brace --no-indent-spaced-block-comments --no-line-up-parentheses --no-outdent-long-comments
--no-outdent-long-quotes --no-space-function-paren # Numeric-value style options --maximum-line-length=120 # Text-value style options # Color options # List-selection style options --brace-tightness=2 --maximum-line-length=120 --paren-tightness=2 --paren-vertical-tightness=2 --square-bracket-tightness=2 # options not supported by tidyview
Configuration in EPIC
其實放到 /etc/perltidyrc 後, EPIC 就會自動讀取這個檔案, 但我發現 EPIC 會主動加上 --maximum-line-length=80, 導致我在設定檔內的設定失效. 所以如果遇到這個狀況, 我的解決方式是在 EPIC 內多加上一個 -l=120,

沒有留言:
張貼留言