在vim中使用perltidy美化perl代码
来源:
http://www.cnblogs.com/itech/archive/2013/02/18/2915279.html
格式优美的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代码不但让人赏心悦目,并且能够方便阅读. perltidy的是sourceforge的一个小项目,在我们写完乱七八糟的代码后,他能像变魔术一样把代码整理得漂美丽亮,快来体验一下吧!! ...
- vim中凝视多行python代码
在vim中凝视多行python代码比較麻烦,主要由下面几种方法: (1)将须要凝视的代码以文档字符串的形式呈现 (2)将须要凝视的代码以函数的形式呈现 (3)使用vim自身快捷键 我们主要使用第三种方 ...
- vim中使用pydiction对python代码进行补全
在配置完vim插件YouCompleteMe之后,在vim编写python的时候按tab键会报错,E121: Undefined variable: g:pydiction_location Pydi ...
- 在eclipse中运行perl代码,需要配置的插件以及方法
Eclipse配置正则表达式 网址:http://www.cnblogs.com/itech/archive/2010/02/23/1671676.html perl的环境配置以及在Eclipse中安 ...
- 在vim中 安装php的xdebug和 vdebug插件, 在vim中进行调试php代码
在vim中 安装php的xdebug和 vdebug插件, 在vim中进行调试php代码 参考: http://www.cnblogs.com/qiantuwuliang/archive/2011/0 ...
- 在 Vim 中使用 pydiction 对 Python 进行代码补全
Pydiction 允许你在 Vim 中实现 TAB 代码补全, 可以补全的内容包括:标准的.自定义的,以及第三方模块和包.外加关键字.BIFs,和字符串. Pydiction 由 3 个主要文件构成 ...
- latex在vim中的代码片段
Gilles Castel写的vim中使用的代码片段,质量很高,原文:https://github.com/gillescastel 下载后,存放到 ~/.vim/plugged/ultisnips/ ...
- 在vi vim中使用正则表达式与 普通perl正则的区别?
参考这篇文章很好 vim中的正则表达式常用的命令有种, 即搜索和替换 /: 搜索 :s 替换 在vim中的正则表达式和perl编程的正则表达式还是有区别的: 正则表达式中的内容包括: 字面字符... ...
- vi/vim使用进阶: 在VIM中使用GDB调试 – 使用vimgdb
vi/vim使用进阶: 在VIM中使用GDB调试 – 使用vimgdb << 返回vim使用进阶: 目录 本节所用命令的帮助入口: :help vimgdb 在UNIX系统最初设计时,有一 ...
随机推荐
- 强制改变IE中的文本模式
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
- L2-001. 紧急救援
L2-001. 紧急救援 题目链接:https://www.patest.cn/contests/gplt/L2-001 Dijstra 本题是dijstra的拓展,在求最短路的同时,增加了不同的最短 ...
- 为什么PHP(CLI)同一个错误信息会打印两次?
第一个信息是display_errors输出的,在fpm环境下输出到浏览器那里,而在CLI环境下会打印到屏幕上. display_errors = On 第二个信息是log_errors输出的. lo ...
- Spring MVC Flash Attribute
转自:Spring MVC Flash Attribute 的讲解与使用示例 Spring MVC 3.1版本加了一个很有用的特性,Flash属性,它能解决一个长久以来缺少解决的问题,一个POST/R ...
- Linux入门(五)linux服务器文件远程管理
1 使用filezila远程管理linux服务器文件 filezila下载地址:https://filezilla-project.org/ filezila默认只能登录普通用户,如果想要root用 ...
- Mysql innodb 间隙锁
前段时间系统老是出现insert死锁,很是纠结.经过排查发现是间隙锁!间隙锁是innodb中行锁的一种, 但是这种锁锁住的却不止一行数据,他锁住的是多行,是一个数据范围.间隙锁的主要作用是为了防止出现 ...
- web小技巧
如内容超出单元格,则隐藏style="TABLE-LAYOUT: fixed" 让弹出窗口总是在最上面: <body onblur="this.focus();&q ...
- spring容器启动的加载过程(三)
第十步: public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { /** * Load bean def ...
- 通过RVM安装Ruby失败
第一次安装失败是由于Homebrew一直安装不成功,遂去http://brew.sh/index_zh-cn.html官网 通过 /usr/bin/ruby -e "$(curl -fsSL ...
- PDO对象
<?php //造DSN:驱动名:dbname=数据库名;host=服务器地址 $dsn = "mysql:dbname=mydb;host=localhost"; //造P ...