vim插件--python_fold代码收起/展开
来源:互联网 发布:anaconda python 2.7 编辑:程序博客网 时间:2024/06/06 09:38
created byJorrit Wiersma script typeutility descriptionThis 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)
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.在vim编辑器里面编写如下代码:(test.c)
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.在vim编辑器里面编写如下代码:(test.c)
//function() {{{
int function() {
......
......
}
//}}}
这个函数体内容会被折叠起来 显示为:
23-30 lines: function() +--------------------------------------------------------+
把光标停留在该显示行上 在非编辑模式下敲击:
zo 展开
zc 收起
zn 全部展开
zN 全部折叠
下载地址:http://vim.sourceforge.net/scripts/script.php?script_id=515
- vim插件--python_fold代码收起/展开
- 展开收起内容实现代码
- 展开、收起div的jQuery代码
- eclipse如何快速收起展开的代码
- 我的第一个封装js代码-----展开收起效果
- Android Studio中如何设置代码展开或收起
- 展开/收起按钮显示隐藏文字js代码
- vim 展开所有折叠代码
- jquery 菜单展开收起
- 展开收起特效
- 展开与收起效果
- js 展开收起效果
- 展开与收起效果
- js图片展开收起
- jquery图片展开收起
- 收起与展开效果
- jquery javascript 展开收起
- Android 展开、收起
- glib for android done
- linux设备驱动模型一三基础结构之Ktype
- 软件项目版本号的命名规则及格式介绍
- 一个请求
- 结合视频资源 深化学习
- vim插件--python_fold代码收起/展开
- 【算法】最大堆实现排序(从大到小输出)【原创技术】
- 安装chromium
- 信息检索(IR)的评价指标介绍 - 准确率、召回率、F1、mAP、ROC、AUC
- JSP文件上传组件--SmartUpload需要注意的问题
- viewDidLoad, viewWillDisappear, viewWillAppear等区别
- 游戏程序员养成计划
- 【java】在Linux上安装jdk
- iPhone开发经典语录集锦