Welcome 微信登录

首页 / 操作系统 / Linux / Vim代码折叠命令简介

1. 通过fdm实现代码折叠:set fdm=xxx有以下6种方式实现折叠:|fold-manual| manual      Folds are created manually.   
|fold-indent| indent      Lines with equal indent form a fold.
|fold-expr|   expr        "foldexpr" gives the fold level of a line.
|fold-marker| marker      Markers are used to specify folds.
|fold-syntax| syntax      Syntax highlighting items specify folds.
|fold-diff|   diff        Fold text that is not changed.   2. 如下配置set fdm=syntax以语法块实现折叠:[root@~/wade/codeReview/redis-2.8.17/src]# cat ~/.vimrc
set nocompatible
set nu
 
"" ctags
map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
"" taglist
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
nnoremap <F8> :TlistToggle<CR>
 
"" 代码折叠
set fdm=syntax3. 折叠基本快捷键说明:zc   折叠
zC   对所在范围内所有嵌套的折叠点进行折叠
zo   展开折叠
zO   对所在范围内所有嵌套的折叠点展开
[z   到当前打开的折叠的开始处
]z   到当前打开的折叠的末尾处
zj   向下移动。到达下一个折叠的开始处。关闭的折叠也被计入
zk   向上移动到前一折叠的结束处。关闭的折叠也被计入--------------------------------------分割线 --------------------------------------把VIM打造成一个简单实用的IDE http://www.linuxidc.com/Linux/2011-06/37032.htmVim学习指南 http://www.linuxidc.com/Linux/2013-08/89096.htm快速学会 Vi编辑器 http://www.linuxidc.com/Linux/2013-08/88586.htm强大的Vim 编辑器 http://www.linuxidc.com/Linux/2013-07/87544.htm在CentOS 6.2上搭建Vim开发环境 http://www.linuxidc.com/Linux/2013-07/87363.htmCentOS 5.4 安装高亮Vim编辑工具 http://www.linuxidc.com/Linux/2013-06/86508.htmVim技巧分享:C语言设置 http://www.linuxidc.com/Linux/2012-12/77124.htmUbuntu中设置Vim的行号 http://www.linuxidc.com/Linux/2012-12/75485.htmVim编辑器使用基础教程 http://www.linuxidc.com/Linux/2013-05/84031.htm--------------------------------------分割线 --------------------------------------本文永久更新链接地址