在Vim中缩进Javascript-函数中Lambda函数的问题 [英] Indenting Javascript in Vim - Problems with Lambda Functions in Functions

查看:65
本文介绍了在Vim中缩进Javascript-函数中Lambda函数的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在vim中使用javascript缩进时遇到问题. 一切工作都很好,除了缩进内联函数作为函数的参数不起作用. 这是一个纯JavaScript的问题(没有涉及html).

I have a problem with javascript indenting in vim. Everything works great, except that the indenting of inline functions as parameters of a function do not work. This is a javascript only problem (no html involed).

示例

someFunc(function() {
    if(foo) {
        bar;
    } else {
        bar;
    }
});

缩进到

someFunc(function() { 
        if(foo) { 
        bar; 
        } else { 
        bar; 
        } 
        });

您有同样的问题吗? 我该如何解决? 我尝试了vim.org上的一些脚本,但它们似乎也有相同的问题.

Do you have the same problems? How can I fix that? I tried some scripts from vim.org but they seem to have the same problem.

一个模仿TextMate javascript缩进功能的脚本将是完美的.

A script that emulates TextMates javascript indenting functionality would be perfect.

推荐答案

Vim用于评估javascript缩进的内置表达式非常糟糕.您可以通过安装更好的Javascript Indentation插件进行修复,或获取如果您更喜欢 github上的资源. /27"rel =" nofollow>将您的插件安装为git子模块.安装此插件将减轻痛苦.每次在一行JavaScript的末尾按回车键时,都应使用正确的缩进级别来定位光标.另外,您将能够使用=命令自动缩进您的javascript.安装该插件-您会想知道没有它会怎样.

Vim's built in expression for evaluating javascript indentation is terrible. You can fix it by installing the Better Javascript Indentation plugin, or get the source on github if you prefer to install your plugins as git submodules. Installing this plugin will ease the pain. Each time you press return at the end of a line of JavaScript, your cursor should be positioned with the correct level of indentation. Also, you'll be able to use the = command to auto-indent your javascript. Install the plugin - you'll wonder how you got by without it.

这篇关于在Vim中缩进Javascript-函数中Lambda函数的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆