在vim中使用perltidy美化perl代码
来源:互联网 发布:最优化方法第二版 编辑:程序博客网 时间:2024/06/06 22:16
格式优美的perl代码不但让人赏心悦目,而且可以方便阅读.
perltidy的是sourceforge的一个小项目,在我们写完乱七八糟的代码后,他能像变魔术一样把代码整理得漂漂亮亮,快来体验一下吧!!!
perltidy 主页: http://perltidy.sourceforge.net/perltidy.html
安装方法:
进入解压后的目录,然后执行一下命令
perl Makefile.PL
make
make test
make install
使用方法:
配置一下vim,使得我们在写代码的时候,不离开vim就可以美化我们代码。
在/etc/vimrc最后一行加入:(意思是快捷键pt来调用perltidy)
map ,pt :%! perltidy
写完perl代码后,在vim命令模式下,输入命令“,pt”就可以直接整理代码格式了。
注意:
1)如果需要安装到自己的home目录下,如下:
perl Makefile.PL PREFIX=~/perl
setenv PERL5LIB ~/perl/lib/site_perl/5.8.3
2)调用时使用config,默认为home目录下的.perltidyrc:
默认地,perltidy yourscript 将生成yourscript.tdy文件, 需要手动用tdy文件覆盖原来的文件。
如果只用指定的配置文件 perltidy -pro=tidyconfigfile yourscript > yourscript.tdy,然后在用tdy文件覆盖原来的文件。
默认的配置文件实例 .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
我的配置文件:
-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
-nsak=s # --nospace-after-keyword=s removes keywords.
-dws # --delete-old-whitespace
完!
- 在vim中使用perltidy美化perl代码
- 在vi中使用perltidy格式化perl代码
- perl vim美化
- 【vim】在vim中使用unix命令
- Vim整合AStyle进行代码美化
- Vim整合AStyle进行代码美化
- Android中在xml中使用shape美化UI
- 在vim中使用make
- 在Vim中使用ctags
- 在Vim中使用ctags
- 在eclipse中使用vim
- 在Eclipse 中使用 vim
- 在vim中使用shell
- 在vim中使用cscope
- 在VS2012 中使用Vim
- 在PowerShell中使用Vim
- 在vim中使用cscope
- 在Vim中使用ctags
- 设置你自己的liux alias
- 为什么使用tmux
- wine下安装wine
- 免费的 jQuery UI 主题集合
- Python-Django的windows环境
- 在vim中使用perltidy美化perl代码
- perl脚本的目录
- Linux 中用 strace 追踪系统调用和信号值
- perl通过文件锁让脚本单实例运行
- Linux下的SSH端口转发
- Perl 之 use(), require(), do(), %INC and @INC
- C++中调用库函数实现快速排序
- Linux技术blogs
- 订阅本博客itech.cnblogs.com