code-formatting

How to create an Intellij and Eclipse compatible code style and code formatting configuration (for java code)?

你说的曾经没有我的故事 提交于 2019-12-17 18:26:17
问题 Few weeks ago I tried Intellij and I found it really awesome. Now, at my project there are two programmers (including me) using Intellij and few other programmers who are going to keep using Eclipse. Since this project is already very large and it's going to grow a lot, we need to use compatible Code Style and Code Formatting between Intellij and Eclipse. We do not want to have problems when one user edits some file and reformats it before saving. With Eclipse "alone" we used to have some

Clang-format line breaks

心不动则不痛 提交于 2019-12-17 15:42:20
问题 I'm looking for a clang-format setting to prevent the tool from removing line breaks. For example, I have my ColumnLimit set to 120, and here's what happens when I reformat some sample code. Before: #include <vector> #include <string> std::vector<std::string> get_vec() { return std::vector<std::string> { "this is a test", "some of the lines are longer", "than other, but I would like", "to keep them on separate lines" }; } int main() { auto vec = get_vec(); } After: #include <vector> #include

Ruby: Can I write multi-line string with no concatenation?

做~自己de王妃 提交于 2019-12-17 14:59:18
问题 Is there a way to make this look a little better? conn.exec 'select attr1, attr2, attr3, attr4, attr5, attr6, attr7 ' + 'from table1, table2, table3, etc, etc, etc, etc, etc, ' + 'where etc etc etc etc etc etc etc etc etc etc etc etc etc' Like, is there a way to imply concatenation? 回答1: There are pieces to this answer that helped me get what I needed (easy multi-line concatenation WITHOUT extra whitespace), but since none of the actual answers had it, I'm compiling them here: str = 'this is

How do you format code in Visual Studio Code (VSCode)

断了今生、忘了曾经 提交于 2019-12-16 22:16:24
问题 This post is a Community Wiki . Edit existing answers to improve this post. It is not currently accepting new answers. What is the equivalent of Ctrl + K + F and Ctrl + K + D on Windows in Visual Studio for formatting, or "beautifying" code in the Visual Studio Code editor? 回答1: The code formatting is available in Visual Studio Code through the following shortcuts: On Windows Shift + Alt + F On Mac Shift + Option + F On Ubuntu Ctrl + Shift + I Alternatively, you can find the shortcut, as well

How do I use code contracts in .NET 4.0 without making my code look cluttered?

廉价感情. 提交于 2019-12-14 00:19:40
问题 I have started using Code Contracts and have found that it makes it difficult to immediately spot the 'guts' of a method. Take this (very simple) example: public static void UserAddNew(string domain, string username, string displayName) { Contract.Assert(!string.IsNullOrWhiteSpace(domain)); Contract.Assert(!string.IsNullOrWhiteSpace(username)); Contract.Assert(!string.IsNullOrWhiteSpace(displayName)); LinqDal.User.UserAddNew(domain, username, displayName); } Now I'm tempted to put the

How to format code on aptana 3?

谁说胖子不能爱 提交于 2019-12-13 16:19:46
问题 It is showing default code format settings in preferences but i can not see any option to format a code file.Please help. Edited: I can format text by selecting text and ctrl+shift+F. But i want to format whole source code or at least a given folder. 回答1: That's not currently an option. I've added a ticket for it here: https://aptana.lighthouseapp.com/projects/35272-studio/tickets/2333-format-whole-folder-of-source-code 回答2: You can format the code by a simple Ctrl+Shift+F. It's actually

Eclipse JavaScript formatter crazy (i.e: too much padding)

白昼怎懂夜的黑 提交于 2019-12-13 11:44:40
问题 I'm having trouble to get eclipse format my JavaScript well. In this first example, it behaves as expected (not the length of the second url): Whenever i have a longer url, eclipse goes crazy formatting my code and I get extra padding everywhere, like the example below: Why does the JavaScript formatter behaving like this, and how do I fix it? (Just in case: I have not installed any formatter plugin, I just use the default that comes with Eclipse Juno) 回答1: The long url in the example affects

IntelliJ Idea: Align on Colon for Scala Case Class Members?

元气小坏坏 提交于 2019-12-13 06:45:53
问题 Is there a way to prevent Idea from reformatting multiline case class members? Intended result (position of the colon is not so important, but the alignment of the type annotations would be great) case class ApiError( timestamp : LocalDateTime, status : Int, code : Option[String], message : String ) I've spent some time in the Code Styling settings for Scala and am stuck with code styling like this: case class ApiError( timestamp: LocalDateTime, status: Int, code: Option[String], message:

How would you format/indent this piece of code?

天涯浪子 提交于 2019-12-13 05:52:08
问题 How would you format/indent this piece of code? int ID = Blahs.Add( new Blah( -1, -2, -3) ); or int ID = Blahs.Add( new Blah( 1,2,3,55 ) ); Edit: My class has lots of parameters actually, so that might effect your response. 回答1: I agree with Patrick McElhaney; there is no need to nest it.... Blah aBlah = new Blah( 1, 2, 3, 55 ); int ID = Blahas.Add( aBlah ); There are a couple of small advantage here: You can set a break point on the second line and inspect 'aBlah'. Your diffs will be cleaner

Netbeans generated code settings

前提是你 提交于 2019-12-13 02:46:32
问题 I was wondering where can I change the way Netbeans generates code. For example, I want the opening bracket to be on a new line. I've been looking in the [Tools] -> [Options] menu but I didn't find anything. 回答1: Solution 1 should solve your problem. For any auto-generated code formatting that Solution 1 won't solve, use Solution 2 . Beware the "Code Templates" tab though, it has been relatively buggy for me in the past. Important Note: Attempting to modify the "Code Templates" for the