简体   繁体   English

Vim jshint错误“在'之前坏线断线','”

[英]Vim jshint error “bad line breaking before ','”

I use jshint.vim and in the code like below I get an error "bad line breaking before ','" 我使用jshint.vim并在下面的代码中得到一个错误“在'之前坏线断开','”

var a = 5
  , b = 10;

How can I fix this? 我怎样才能解决这个问题? I found this question , but I'm not sure how can I use it to fix the problem in Vim. 我发现了这个问题 ,但我不确定如何使用它来解决Vim中的问题。 Is there any config file (except .vimrc) where I can set laxbreak or laxcomma ? 有没有配置文件(除了.vimrc)我可以设置laxbreaklaxcomma

Yes. 是。 I often use a leading comma style, and set the following preferences inside ~/.jshintrc : 我经常使用领先的逗号样式,并在~/.jshintrc设置以下首选项:

{  
//...other prefs
laxcomma  : true,
laxbreak  : true,
//... other prefs
}

If you don't already have a .jshintrc, those two settings enclosed in braces a la JSON will probably do the trick. 如果你还没有.jshintrc,那么用大括号a JSON括起来的那两个设置可能就可以了。

I'm not sure about global configurations for the vim implementation, you'd have to consult the docs for that implementation, but you can put 我不确定vim实现的全局配置,你必须查阅该实现的文档,但你可以把

/*jshint laxcomma:true */

at the top of your source files to set this on a per-file basis 在源文件的顶部,以每个文件为基础进行设置

Update 更新

Looks like for the vim implementation you can set the config file using a global variable: 看起来对于vim实现,您可以使用全局变量设置配置文件:

https://github.com/walm/jshint.vim/pull/3 https://github.com/walm/jshint.vim/pull/3

You can then just create a json file and set laxcomma:true in it. 然后,您可以创建一个json文件并在其中设置laxcomma:true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM