haskell的良好的代码风格

1741阅读 1评论2012-05-20 bailiangcn
分类:LINUX

发现一篇关于haskell代码风格的建议的文档(),后面有如何配置vim适应该风格()。
简单总结一下:使用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


上一篇:俞敏洪:面对未来的教育
下一篇:与haskell相关的vim插件

文章评论