北漂IT民工 的博客

在Vim里让javascript折叠

英文源于:


http://verens.com/archives/2005/04/18/using-javascript-folds-in-vim/


1.修改vimrc文件, 添加下面一行:

let javaScript_fold=1


2.de>编辑/usr/share/vim/vim(7.x)/syntax/javascript.vim

括号里的7.x要修改成自己相应的目录。我的目录是:

de>de>/usr/share/vim/vim72/syntax/javascript.vimde>


找到这段话:


if exists(“javaScript_fold”)

syn match javaScriptFunction “

syn region javaScriptFunctionFold start=”.[^};]$” end=”^z1}.$” transparent fold keepend


syn sync match javaScriptSync grouphere javaScriptFunctionFold “

syn sync match javaScriptSync grouphere NONE “^}”


setlocal foldmethod=syntax

setlocal foldtext=getline(v:foldstart)

else

syn keyword javaScriptFunction function

syn match javaScriptBraces “[{}]”

endif


syn sync fromstart


syn sync maxlines=100


将他们替换成:


syn region myFold start=”{“ end=”}” transparent fold

syn sync fromstart

set foldmethod=syntax

set foldtext=getline(v:foldstart)

syn sync maxlines=100


即可