vim插件--python_fold代码收起/展开
2012-05-13 08:05
288 查看
created by |
Jorrit Wiersma |
script type |
utility |
description |
This script uses the expr fold-method to create folds for python source code. Folds are created for: - Class definitions - def function definitions - Blocks between {{{, }}} markers (but not yet {{{n, etc.) The fold level for each fold is equal to the indentation divided by the value of the 'shiftwidth' option, so make sure that 'shiftwidth' is set to the right value for your code. Class and function folds show a count of the number of lines in the fold and the documentation string when closed (contributed by Max Ischenko). Caveats: - The docstring is not shown when it is enclosed in single quotes (like '''comment'''); use double quotes instead (like """comment""") - Newest version relies on a blank line following class or function definition if the next bit of code is not a new class or function definition. If this doesn't suit your programming style, use the _nonblank version 2.2 (nb). That version is buggier, however. Do not install both files. Bugs: - It occasionally inserts a bogus fold at complicated structures like conditionals that are followed by a blank line. A work-around is to remove the blank line or to replace it with a line containing a comment (a single '#' will do) |
install details |
Choose either python_fold.vim or python_fold_nonblank.vim (do not use both at the same time!). Either save it in a file and source that file whenever you want to use the folding, or save it in your ftplugin directory (for example, ~/.vim/ftplugin) and it should load every time you edit python code. |
//function() {{{
int function() {
......
......
}
//}}}
这个函数体内容会被折叠起来 显示为:
23-30 lines: function() +--------------------------------------------------------+
把光标停留在该显示行上 在非编辑模式下敲击:
zo 展开
zc 收起
zn 全部展开
zN 全部折叠
下载地址:http://vim.sourceforge.net/scripts/script.php?script_id=515
相关文章推荐
- vim中编写python代码使用python-mode和syntastic插件时警告(Warning)的消除
- 使用pep8 vim插件规范Python代码
- [亲测] 使用pep8 vim插件规范Python代码
- Python-mode:在 Vim 编辑器中开发 Python 应用的 Vim 插件
- JS+CSS实现可展开/收起的QQ在线客服悬浮代码
- gvim写html代码时如何快速地跳转到一个标签的结束位置: 终极插件: matchit.vim
- 【ubuntu】vim安装python自动补全插件(2)
- 使用vim作为python ide -插件管理
- [vim]clang带来的clang complete代码补全插件
- VIM 代码片段插件 ultisnips 使用教程
- 展开/收起按钮显示隐藏文字js代码
- VIM python 自动补全插件:pydiction
- Vim中C/C++代码补全插件-omnicppcomplete
- linux 下 vim编辑器插件安装 方便python脚本编写
- VIM python 自动补全插件:pydiction
- 在 Vim 编辑器中开发 Python 应用的 Vim 插件
- vim 启用python插件
- python开发vim插件
- Linux VIM python 自动补全插件:pydiction
- 利用Vim给Python代码自动加入头部必须注释