code-formatting

Roslyn - replace node and fix the whitespaces

为君一笑 提交于 2019-12-01 06:54:53
In my program I use Roslyn and I need to replace a node with a new node. For example, if I have code like public void Foo() { for(var i = 0; i < 5; i++) Console.WriteLine(""); } and I want to insert brackes for for statement, I get public void Foo() { for(var i = 0; i < 5; i++) { Console.WriteLine(""); } } I tried to use NormalizeWhitespace, but if I use it on for statement, I get public void Foo() { for(var i = 0; i < 5; i++) { Console.WriteLine(""); } } However, I'd like to have for statement formatted correctly. Any hints how to do it? EDIT: I solved it by using: var blockSyntax =

PHP-Netbeans: How to change formatting for multi-conditional if statements

假如想象 提交于 2019-12-01 02:59:59
问题 I have the following Code: if( condition1 && condition2 && condition3 ) { // do something } And after having netbeans reformat it i get if( condition1 && condition2 && condition3 ) { // do something } which is not what I want. I already tried changing Editor>Formatting>PHP>Wrapping>If Statement - but I could not even figure out what this option does, but at least it seems not to solve my issue. How can I make netbeans format multiconditonal ifs as I like them (or just leave them as they are)?

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

爱⌒轻易说出口 提交于 2019-11-30 22:10:46
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 know, is if there's a way I can somehow automatically format the contents of the textfile in the same

Resharper formatting code into a single line

瘦欲@ 提交于 2019-11-30 18:56:18
I am having an issue with formatting code with Resharper. I have disabled the option for wrapping lines. With this option, the following code will be formatted to a single line. Does anyone have an idea how to have Resharper not format the following code? Mapper.CreateMap<CountryEntity, Country>() .ForMember(dest => dest.CreatedBy, map => map.MapFrom(src => src.CreatedBy)) .ForMember(dest => dest.DateCreated, map => map.MapFrom(src => src.DateCreated)) .ForMember(dest => dest.Id, map => map.MapFrom(src => src.Id)) .ForMember(dest => dest.Name, map => map.MapFrom(src => src.Name)) .ForMember

Resharper formatting chained method

允我心安 提交于 2019-11-30 18:36:08
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(); 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# -> Formatting Style -> Line Breaks and Wrapping -> Line Wrapping -> Wrap chained method calls to Chop always

Auto-formatting tool for VBscript

孤者浪人 提交于 2019-11-30 17:20:41
I'm looking for a light, free tool to format my Vbscript code. The only way I've found so far is to auto-format it in VisualStudio. Although, it's too much to launch VisualStudio for this purpose. Is there any web app or a free light tool for this purpose? Maybe a plugin for Notepad++? Have you tried: VB Indent - paste your VBScript or VB code, press the button, and it'll indent for you. or ASP Indent - auto formatting of your ASP Code. It will not format HTML, though. It's only checking and formatting the text between the <% %> There don't appear to be any user settings, but it works! Vidaya

How to format code in Visual Studio Code

时光毁灭记忆、已成空白 提交于 2019-11-30 16:49:47
Hello I am asking how to format code in Visual Studio Code the last update on Windows . I tried ctrl k+ Ctrl d doesn't work .. I also tried Shift + Alt + F . it didn't work too. So please help me and it isn't duplicate because i tried the following solution: How do you format code in Visual Studio Code (VSCode) if you are working on php you should download php exension format code. Press F1 and type : ext install PHP Code Format . Then Shift + Alt + F will work hamiltonia You can also select the code you want to format and right click , find the format code menu item and it should have the

Code polisher / reformater for C, C++ or Fortran [closed]

若如初见. 提交于 2019-11-30 10:48:26
Suppose you have got a bunch of files written in C, C++ or Fortran, by different authors, with different opinions on formatting, how to comment, and so on. I think many people know situations like these. Are there any free tools for ends like: uniform format of code (indent, etc.) create standard comment bodies rename variables ? For Fortran there is plusFORT, which can do much more than what you ask for, such as reorganizing code and translating from FORTRAN 77 to Fortran 90. See http://www.polyhedron.com/pf-plusfort0html and http://www.polyhedron.com/pflinux0html Have a look at AStyle . It's

How can I indent multiple lines in Xcode?

拥有回忆 提交于 2019-11-30 10:03:04
问题 When I select multiple lines of code and want to indent them as usual with TAB key, it just deletes them all. I come from Eclipse where I always did it that way. How's that done in Xcode? I hope not line by line ;) 回答1: The keyboard shortcuts are ⌘ + ] for indent and ⌘ + [ for un-indent. In Xcode's preferences window, click the Key Bindings toolbar button. The Key Bindings section is where you customize keyboard shortcuts. 回答2: Select your code to reindent, then Go to Editor -> Structure ->

Are there any free cmd-line scripts which can re-format PHP source-code?

拟墨画扇 提交于 2019-11-30 09:27:59
问题 I'm using a pre-commit hook to lint-check PHP source submitted by our staff, and everyone's really happy with the results. The staff have agreed it would be useful to have the code re-formatted to follow (customizable) style rules on commit. Are there any FOSS scripts which can do this from the command-line? 回答1: Was looking for the same thing, just came across the PHP Beautfier package in the PEAR repository: http://pear.php.net/package/PHP_Beautifier Hope this helps! 回答2: PHP_CodeSniffer is