code-formatting

Formating javascript source code [closed]

家住魔仙堡 提交于 2019-11-30 09:08:32
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . There is js file with a lot of code in unreadable format (all code in one line): JS file Is there a tool to format to a "normal" view? 回答1: The developer tools, integrated in most modern browsers, are capable of cleaning up the formatting. As an example, below is an animated GIF showing how you can achieve this

Spring - adding BindingResult to newly created model attribute

梦想与她 提交于 2019-11-30 08:15:18
My task is - to create a model attribute by given request parameters, to validate it (in same method) and to give it whole to the View. I was given this example code: @Controller class PromotionController { @RequestMapping("promo") public String showPromotion(@RequestParam String someRequestParam, Model model) { //Create the model attribute by request parameters Promotion promotion = Promotions.get(someRequestParam); //Add the attribute to the model model.addAttribute("promotion", promotion); if (!promotion.validate()) { BindingResult errors = new BeanPropertyBindingResult(promotion,

Disable Visual Studio code formatting in Razor

微笑、不失礼 提交于 2019-11-30 06:42:13
问题 This has been asked before: Why doesn't Visual Studio code formatting work properly for Razor markup? But that question is a couple years old. And Razor formatting is still completely unacceptable. I have given up on fixing it. Can I disable ALL Visual Studio formatting for CSHTML files? If not, can I disable all Visual Studio formatting entirely? Any 3rd party hacks I can use? There's got to be something! I've upgraded to 2013 and the formatting is just as bad. [EDIT]: 2015 is god-awful as

Stop Eclipse from mangling my comments

折月煮酒 提交于 2019-11-30 06:03:04
Is there a way to stop eclipse from mangling the comments in my source files? My main issue is stopping it from word wrapping them. I've managed to configure eclipse to not word wrap any code but it still seems to do it to comments. Code that I enter like this: public int myVariable = 100; // this variable is a very interesting variable and it does lots of stuff End up like this: public int myVariable = 100; // this variable // is a very // interesting // variable and // it does lots // of stuff Go to the "Window" menu -> preferences choose the editor you're interested in from the list on the

C# to format (indent, align) C# properly

依然范特西╮ 提交于 2019-11-30 04:54:33
问题 We have a code generator that munges the schema of a given database to automate our inhouse n-tier architecture. The output is various C# partial classes, one per file. In the code to munge all the strings, we try and keep on top of the indenting and formatting as much as possible, but invariably when you come to open the file in Visual Studio the formatting is awry. A quick ctrl-k, ctrl-d fixes it, but obviously this reformatting is lost the next time the class is generated. What I'd like to

how to align arguments to functions in emacs?

我们两清 提交于 2019-11-30 04:13:47
Say if I have the following: func(arg1, arg2, arg3...) func(longargarg1, longerarg2, arg3,...) ... How do I align the arguments so that it's like following? func(arg1 , arg2 , arg3...) func(longargarg1, longerarg2, arg3,...) ... [I can use M-x align-regex to align the first argument, but I cannot cook up with a suitable regex to align the rest of the arguments. Bonus point if the answer also take cares of the case when some arguments are strings with commas in them.] Select the region, then: C-u M-x align-regexp RET ,\(\s-*\) RET RET RET y The regexp says to align commas with spaces following

Resharper formatting chained method

丶灬走出姿态 提交于 2019-11-30 03:00:33
问题 Is there a setting in R# to format chained method to start at the same character of the class instantiated. What I want: var foo = new FooDataBuilder() .WithDate(myDate) .WithBar(myBar) .Build(); What R# is giving me: var foo = new FooDataBuilder() .WithDate(myDate) .WithBar(myBar) .Build(); 回答1: With Resharper 7.1.2, you can get the following formatting: var foo = new FooDataBuilder().WithDate(myDate) .WithBar(myBar) .Build(); By setting the following Resharper options: Code Editing -> C# ->

Visual Studio Ctrl K + D (code formatting) not working

三世轮回 提交于 2019-11-30 00:34:21
问题 Ctrl K + D in a Visual Studio 2010 Sharepoint project is not working in some files as they contain paths to some resources (masterpageurl/images/js/css classnames) that get generated at runtime. How do I make VS to "ignore" checking if these resources exist or not? 回答1: Code formatting doesn't work in multi-line arrays : int[] ok={ 1 , 2, 3 }; int[] ko={ 1 , 2, 3 }; use Ctrl K + D int[] ok = { 1, 2, 3 }; // nice formatting int[] ko ={ 1 , 2, 3 }; // nothing changed :( 回答2: Check for other

Intellij-IDEA: How to sort members alphabetically?

戏子无情 提交于 2019-11-30 00:18:32
问题 I am using Intellij-IDEA 12. Most of team mates use Eclipse and while saving it sorts members automatically first based on Visibility and then Alphabetically. I want to mimic the same functionality in Intellij. But it seems that when I choose arrange members alphabetically, it overrides visibility (and all other) rules. How can I sort members based on Visibility (Public - Default - Private ) and within that sub-group sort them Alphabetically? Edit: This assumption made in the question is

How do I comment in CoffeeScript? “/* this */” doesn't work

杀马特。学长 韩版系。学妹 提交于 2019-11-29 22:43:41
In what ways can you comment in CoffeeScript? The documentation say you can use three hash symbols to start and close a comment block: ### Comments go here ### I've found that I can sometimes use the following two formats `// backticks allow for straight-JavaScript, // but the closing backtick can't be on a comment line (I think?) ` Are there a simpler way to insert short comments in CoffeeScript? Do NOT use this style** Since this is getting a lot of views, I want to emphasize that /* Comment goes here */ produces a MATH error when the /* is on its own line. As Trevor pointed out in a comment