code-formatting

How do I modify Eclipse code formatting?

混江龙づ霸主 提交于 2019-12-28 02:51:09
问题 When I reformat code with Eclipse, it turns method headers like this: public void myMethod(String param) { into method headers like this: public void myMethod( String param) { When I was brought on here I'd never used Eclipse before, and I imported project settings provided by someone else. I have seen that on small new projects I've worked on Eclipse does not do this, so it must be in the settings I've imported. But I've gone through every panel I can find, as well as every hidden file I can

How can I prevent ReSharper from inserting a blank line between my MSpec fields?

余生颓废 提交于 2019-12-24 17:09:25
问题 When I write an MSpec context like this: [Subject(typeof(TheType), "Concern")] internal class when_this_test_is_run { Establish context = () => { // some code... }; Because of = () => Do.Something(); It should_do_this; It should_do_that; } When I let ReSharper reformat the code, it always inserts a blank line beneath any of the delegates that is an anonymous method, i.e. has a { block } as its body. It doesn't insert blank lines after delegates that are simple expressions. So in the example

Programmatically export eclipse formatter profile XML into .prefs

雨燕双飞 提交于 2019-12-24 12:08:18
问题 My team uses code formatting conventions defined in an eclipse profile XML file that looks something like this: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <profiles version="12"> <profile kind="CodeFormatterProfile" name="This Team's Formatting Convention" version="12"> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/> ... I am using eclipse as a command-line formatter, using a command like the following: eclipse -nosplash -application org

Merge strategy for whitespace only changes?

半城伤御伤魂 提交于 2019-12-24 01:20:00
问题 I did a code format in master branch. It mainly fixed whitespace issues like: formatting tab space lengths, adds and removes newlines before and after braces. The problem is, when I try to merge master from other branches I get a lot of conflicts. Is there some strategy to bring in whitespace changes to other branches? 回答1: From the docs of git merge, I would assume that git merge -s recursive -Xignore-space-change could be used to achieve this. You might also want to play around with

How to create my own 'Reformat Code' style in Android Studio?

僤鯓⒐⒋嵵緔 提交于 2019-12-23 20:54:39
问题 In Eclipse,(Window -> Preferences -> Java -> Code Style -> Formatter) there was a facility to create my own format style and apply it in the code. Is there a way to do that in Android Studio(for Java code) ? 回答1: To change formatter options go to File | Settings | Code Style | Java To reformat your code manually, press Ctrl + Alt + L (or using the menu Code | Reformat code... ). To reformat the whole source code of your module, just select the module folder first. More information about

Disable Code Formatting for a specific block of code in Visual Studio

拈花ヽ惹草 提交于 2019-12-23 15:50:48
问题 I was wondering if there's a way to disable code formatting for a specific block of code in Visual Studio 2017 (C# 7). I have this method: public CarViewModel(ICarsRepo carsRepo) { ... Manufacturers = ToSelectList<Manufacturer>(); Categories = ToSelectList<Category>(); States = ToSelectList<State>(); } And I would like to format it like so: public CarViewModel(ICarsRepo carsRepo) { ... Manufacturers = ToSelectList<Manufacturer>(); Categories = ToSelectList<Category>(); States = ToSelectList

How do I force MS Access to retain its SQL formatting?

末鹿安然 提交于 2019-12-23 07:17:06
问题 I have a lot of SQL at work in MS-Access, and I need to formatted so that it's human readable. The issue is when I change between views I end up with the SQL being condensed down into something that I can't read. How do I force SQL to retain its 'shape' when I go to other views? 回答1: I found a hack, here. The secret lies in enclosing your query inside a dummy query. Like so: SELECT * FROM (SELECT <-----here Table1.Field1, Table1.Field2 FROM Table1 WHERE Table1.Field2 = "Yes") AS query1 <----

When can I use newlines (line breaks) in my Powershell commands to improve readability

时间秒杀一切 提交于 2019-12-22 21:54:33
问题 How do I know when I can use a New Lines/Carriage returns in my Powershell scripts? All of the search results when searching for this answer all point to the Output. I don't care about the output in this case. I am more interested in my ability to format my Powershell scripts for readability. For Example. Two versions of a Powershell command line below. One works and one doesn't. What the command does in unimportant in this case. The point is I am needing to know when I'm allowed to create a

Can the Eclipse code style formatter align assignment statements?

扶醉桌前 提交于 2019-12-22 12:25:32
问题 Eclipse has an option in Indentation: "Alignment of fields in class declarations" that will align assignments of class members as in: class Foo { int x = 3; String y = "abc" long z = 2; } Is there a setting that will do the same for method level assignments as in: private void foo() { int x = 3; String y = "abc" long z = 2; } I can not find such a setting. 回答1: Try creating a new Java Code Style Formatter profile (Window->Prefernces->Java->Code Style->Formatter) or modifying an older one and

my vs2008 addin for textformatting is awfully slow

倖福魔咒の 提交于 2019-12-22 10:15:03
问题 i wrote a little addin, which does some formatting of my C# code. in the addins Exec method i do the following try { TextSelection selection = (EnvDTE.TextSelection)_applicationObject.ActiveDocument.Selection; String foo = String.Empty; if (!text.IsEmpty) { foo = someCoolObjectThatFormatsText.Format(selection.Text); selection.Text = foo; // here everything gets painfully slow :-( } } catch (Exception) { throw; } when the line with the code "SelectedText.Text = foobar;" is call, VS rebuilds