咖啡脚本定制折叠
对于“标准”JavaScript,我有一个我非常喜欢的自定义折叠函数:
function! JavaScriptFold()
setl foldmethod=syntax
setl foldlevelstart=1
set fillchars=fold:\
syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend
function! FoldText()
return substitute(getline(v:foldstart), '{.*', '{...}', '')
endfunction
setl foldtext=FoldText()
endfunction
请问有好心人可以告诉我这个 CoffeeScript 的翻译吗? 因此,它
testFunction = (x) ->
x + x
会像这样折叠到第一行,只是
testFunction = (x) ->
折叠文字对象的奖励点,但功能已经很棒了!
PS:当然,我使用的是 Vim 的咖啡脚本插件
For "standard" JavaScript, I have this custom folding function which I like a lot:
function! JavaScriptFold()
setl foldmethod=syntax
setl foldlevelstart=1
set fillchars=fold:\
syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend
function! FoldText()
return substitute(getline(v:foldstart), '{.*', '{...}', '')
endfunction
setl foldtext=FoldText()
endfunction
Could a kind soul please show me a translation of this for CoffeeScript?
So that
testFunction = (x) ->
x + x
would be folded like this into its first line only
testFunction = (x) ->
Bonus points for folding literal objects too, but functions would be great already!
PS: of course, I'm using the coffee-script plugin for Vim
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于我不了解咖啡,也不知道它支持哪些文字对象,所以我无能为力。但是,您想要的可以通过此设置来实现(可以转换为模型行):
您没有指定在折叠上显示的内容,所以我将其省略。您可以使用折叠文本设置。请参阅
:h Fold-foldtext
来了解这一点。As I don't know cofee, and I don't know what literal objects it support, I can't help with that. However what you want, can be achieved by this setting (which could be translated into a modeline):
You didn't specify what to display on the fold, so I left this out. You can use the foldtext setting for that. See
:h fold-foldtext
for that.