如何停止Visual Studio在函数定义和立即调用之间插入空格? [英] How do I stop visual studio inserting a space between function definition and immediate call?

查看:82
本文介绍了如何停止Visual Studio在函数定义和立即调用之间插入空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio JSLint插件来使我的javascript井井有条,除了这个问题之外,它似乎工作得很好.

I am using the visual studio JSLint plugin to keep my javascript in order, which seems to work really well apart from this one problem.

如果我输入

x = (function () {
}())

然后将分号放在最后,Visual Studio会将其更正为:

And then put the semicolon on the end, Visual studio corrects it to:

x = (function () {
} ());

然后JSLint抱怨JS Lint: Unexpected space between '}' and '('.

And then JSLint complains JS Lint: Unexpected space between '}' and '('.

显然,这可以通过删除空间来解决,但是Visual Studio在将空间放回原处非常坚持.将分号放在函数内部(文件的大部分内容)中的任何位置,将导致VS放回空格.这开始变得烦人了.

Obviously this is fixable by removing the space, but visual studio is very persistent in putting the space back. Putting a semicolon anywhere inside the function, which is most of the file, will cause VS to put the space back. This is starting to get annoying.

我已经尝试过使用Visual Studio Javascript编辑器设置(在...后面插入空格"),但似乎无法阻止它这样做.

I've tried mucking about with the visual studio Javascript editor settings ('insert space after...'), but can't seem to stop it doing this.

这可以表达的另一种方式是

Another way this could be expressed is

x = (function () {
})();

哪个VS留下,但是JSLint说JS Lint: Move the invocation into the parens that contain the function.在那里没有骰子.

Which VS leaves alone, but JSLint says JS Lint: Move the invocation into the parens that contain the function. So no dice there.

有什么建议吗?我知道即使在文件的最后一行附近,我也可以关闭JSLint的位,但这看起来很混乱,我想做得更好.

Any suggestions? I know I can turn bits of JSLint off, even just around this last line of the file, but that's going to look messy, I'd like to do a bit better.

推荐答案

我没有关闭空白格式设置规则检查的更好响应,但这是非常不幸的.据我所知,这里描述的这种情况是唯一的情况,即Visual Studio自动格式化和jslint以无法合理配置的方式发生冲突.

I don't have a better response than turning off whitespace formatting rule checking, but this is very unfortunate. As far as I can tell, this one situation described here is the only case were visual studio automatic formatting and jslint collide in a way you can't reasonable config your way out of.

丢失对该源文件的整个空格检查,或者丢失其余JavaScript的自动重新格式化,都是解决此问题的大手笔方法.如果有人有一个,我很乐意看到另一个创意选择.

Losing the entire whitespace checking for this source file, or losing the auto reformatting of the rest of your JavaScript, are both somewhat sledgehammer approaches to this problem. I'd love to see another creative option if anyone has one.

这篇关于如何停止Visual Studio在函数定义和立即调用之间插入空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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