Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1696447
  • 博文数量: 410
  • 博客积分: 9563
  • 博客等级: 中将
  • 技术积分: 4517
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-03 19:59
个人简介

文章分类

全部博文(410)

文章存档

2017年(6)

2016年(1)

2015年(3)

2014年(4)

2013年(32)

2012年(45)

2011年(179)

2010年(140)

分类: LINUX

2012-05-20 22:29:46

发现一篇关于haskell代码风格的建议的文档(),后面有如何配置vim适应该风格()。
简单总结一下:
  • 别留下行尾的空白。
  • 别使用tab。
  • 每行别超过80个字符宽度。
  • 使用驼峰式变量命名方式。
  • 别使用大括号和分号来定义代码,尽量使用缩进的方式。
使用vim来满足以上要求的配置。
Eliminating tabs

In order to have your tab key generate the appropriate the appropriate number of spaces rather than a tab character, add this to .vimrc:

  1. set expandtab

If you have a file that already contains tabs then you can convert them to spaces by typing :retab. You may need to set your tabstops correctly first, with e.g. :set ts=8.

Eliminating trailing whitespace

If you have a file that contains trailing whitespace then you can remove it all by typing :

  1. %s/ \+$//.

Highlighting bad whitespace

If you create .vim/after/syntax/haskell.vim with the following contents, then any tab characters and trailing space will be highlighted for you:

  1. syn cluster hsRegions add=hsImport,hsLineComment,hsBlockComment,hsPragma
  2. syn cluster hsRegions add=cPreCondit,cCppOut,cCppOut2,cCppSkip
  3. syn cluster hsRegions add=cIncluded,cDefine,cPreProc,cComment,cCppString

  4. syn match tab display "\t" containedin=@hsRegions
  5. hi link tab Error
  6. syn match trailingWhite display "[[:space:]]\+$" containedin=@hsRegions
  7. hi link trailingWhite Error


阅读(1628) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

星期五啦2012-05-21 21:43:23

呵呵,风格这个东西看似随意,其实很大的学问~