code-formatting

Unexpected behavior with “git commit .” when pre-commit hook modifies staged files

房东的猫 提交于 2020-04-15 03:45:31
问题 In my experience git commit -a has had equivalent behavior to git commit . However, recently I have created a pre-commit hook that automatically formats my source code and now git commit . has some unexpected side-effects: the file that is committed ends up as modified in the working directory and in the index after the commit command finishes. This doesn't happen with git commit -a . I'm trying to understand what is going on behind the scenes when running git commit . that is causing this to

Beautify on save in VS code?

ⅰ亾dé卋堺 提交于 2020-04-08 09:27:25
问题 I just installed a beautify extension for vs code I want to have my code beautified whenever I save a file, but can't figure out how to configure it that way. It says Beautify on save will be enabled when "editor.formatOnSave" is true. But i have no idea where to put it exactly as I cannot find the default option in any of the files. I'm trying to switch to VS code and figure things out. 回答1: For Windows click on 'File' -> Preferences -> Settings. Then search for editor.formatOnSave, and put

Beautify on save in VS code?

不打扰是莪最后的温柔 提交于 2020-04-08 09:27:13
问题 I just installed a beautify extension for vs code I want to have my code beautified whenever I save a file, but can't figure out how to configure it that way. It says Beautify on save will be enabled when "editor.formatOnSave" is true. But i have no idea where to put it exactly as I cannot find the default option in any of the files. I'm trying to switch to VS code and figure things out. 回答1: For Windows click on 'File' -> Preferences -> Settings. Then search for editor.formatOnSave, and put

Dealing with ASP.NET MVC “tag soup”

不羁岁月 提交于 2020-02-28 05:53:44
问题 I was working on an ASP.NET MVC template today, and after staring at all those fluorescent yellow % tags for long enough, I basically decided I had had enough, so I painstakingly modified my ascx file to look like this: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <% if (Model == null) { %> <%= ViewData.ModelMetadata.NullDisplayText %> <% } else if (ViewData.TemplateInfo.TemplateDepth > 1) { %> <%= ViewData.ModelMetadata.SimpleDisplayText %> <% } else { %> <% foreach

Groovy formatter/beautifier in Visual Studio Code

非 Y 不嫁゛ 提交于 2020-02-26 09:02:06
问题 For supported files in VSCode we get an option (when you right click on the file editor) to Format Document (ALT+SHIFT+F) . But unfortunately for Groovy this option is not available. And according to the VSCode community, there are no plans to implement this feature. Is there an alternative solution available, specifically for VSCode? 回答1: I don't know how well this works for formatting other than indentation, but I simply changed the file extension from .groovy to .js, right clicked in the

Prevent Visual Studio 2015 from removing line continuation characters (_) in VB.NET files

会有一股神秘感。 提交于 2020-02-24 17:49:10
问题 I'm opening some old VB.NET projects in Visual Studio 2015 and when I edit the code, VS changes the syntax: It removes "_" in concatenations: 'Before myString = "ABC" & _ "DEF" 'After myString = "ABC" & "DEF" or add a space before !: 'Before myDatatable.Rows(0)!myColumn 'After myDatatable.Rows(0) !myColumn This syntax isn't compatible with Visual Studio 2010 or 2013. How can I disable this changes? 回答1: I had the same problem, and I was able to fix it by disabling the "Pretty listing" option

Automatic indentation of arguments list on multiple lines in Visual Studio

徘徊边缘 提交于 2020-02-21 10:40:27
问题 When the list of arguments to a method grows to the point where they do not fit comfortably on one line, I like to format code such that each argument is on a separate line (following StyleCop suggestion), like this: public void MyMethod( int someArgument, double someOtherArgument, int someMoreArguments) The problem I run into is that this formatting is "fragile" and does not get automatically re-formatted when using Ctrl+K+D. For instance, if I happen to insert some spaces in front of one of

Automatic indentation of arguments list on multiple lines in Visual Studio

孤街醉人 提交于 2020-02-21 10:40:26
问题 When the list of arguments to a method grows to the point where they do not fit comfortably on one line, I like to format code such that each argument is on a separate line (following StyleCop suggestion), like this: public void MyMethod( int someArgument, double someOtherArgument, int someMoreArguments) The problem I run into is that this formatting is "fragile" and does not get automatically re-formatted when using Ctrl+K+D. For instance, if I happen to insert some spaces in front of one of

How to format django template in Sublime Text

耗尽温柔 提交于 2020-01-24 02:13:06
问题 How can one format django template in Sublime Text. My template consists of: HTML (django template language with {{ variable }} and {% stuff %} ) javascript Is there a way to get same kind of formatting PyCharm provides? 回答1: This package should help: https://github.com/squ1b3r/Djaneiro Here are some tips on install: How to install plugins to Sublime Text 2 editor? 回答2: A couple different things: Djanerio has a nice set of auto-completion and color schemes specific to Django. Check out their

Resharper C# Formatting Style shows “new” on new line instead of same line when chopping long lines

爱⌒轻易说出口 提交于 2020-01-22 12:16:40
问题 So Resharper is putting a line break before the "new" in my code when re-formatting it as follows: var foo = new Foo { Bar = null, Baz = new Baz { Bap = null, Bork = null, Help = new PweaseHelp { Korben = null, Dallas = null, Multipass = null }, Me = new ClearlyMyAbilityToUnderstandResharperSettingsIs( null), } }; But I'd really like it too do this: var foo = new Foo { Bar = null, Baz = new Baz { Bap = null, Bork = null, Help = new PweaseHelp { Korben = null, Dallas = null, Multipass = null }