code-formatting

Visual Studio C++ “Automatically format completed block on }”

你。 提交于 2019-12-22 09:06:04
问题 Visual Studio has this setting for C#, but I can't find it for C++. "Automatically format completed block on }" I used this feature a lot while working on C# stuff & now that I'm back on C++ (which I prefer), I miss the feature. How can I set this up? I assume I'd have to use a 3rd party plugin or something at this point, but I can't find any relevant ones in all my searching. What the feature does: If I have a section of code & type '{' before it, then type '}' after it, it will

Generating well-formatted syntax with Roslyn

你离开我真会死。 提交于 2019-12-22 06:55:52
问题 I am using Roslyn to modify the syntax of C# files. Using CSharpSyntaxRewriter, it is very easy to find and replace nodes in the syntax tree. However, the generated code is very ugly and won't even parse in all cases because the syntax nodes I create (using SyntaxFactory) lack even a minimal amount of whitespace trivia. Does Roslyn provide some basic formatting functionality to avoid this or do I have to add trivia manually to each node I create? 回答1: Yes - it is possible, using Microsoft

Writing a comment in Eclipse linking a specific line

百般思念 提交于 2019-12-22 03:52:11
问题 i'm working with Eclipse in Java and with long long classes i need a feature like this: in the top comment of a method (for example) there is a list of operations executed by the method. For each operation listed, i'd like to "hyperlink" a portion of the comment to a specific line of the related code. Then using Ctrl+Click to that line i can jump directly to the specified line code. Is it possible an operation like this? Thanks 回答1: In the comment below your question you say: how can i link

Java API for source formatting

白昼怎懂夜的黑 提交于 2019-12-21 18:36:10
问题 There are several PHP or js code formatting libs out there -- does anyone know if similar libs exist in Java? Ie., Given a string of code, return a formatted string with syntax colouring etc. It'd be ideal if it auto detected the language, but I might be pushing my luck there... The text will ultimately be displayed within a Flex application, so while I could use a js lib, we'll be parsing large files (up to 6000 lines), so I'd like to keep client side processing minimal. Ideal output is HTML

Eclipse: Lining up function arguments vertically

陌路散爱 提交于 2019-12-21 03:14:20
问题 I'm running Eclipse 3.7.2 on Windows 7 professional. If I type a method declaration like this: private void processCode(String codename, boolean doSomethingElse, int num_of_repeats){ } Then hit Ctrl + I with the whole file selected, Eclipse will mess up the alignment of the function arguments like this private void processCode(String codename, boolean doSomethingElse, int num_of_repeats){ } How can I get Eclipse to stop doing that? 回答1: Follow these steps to achieve what you want: Open the

Set Visual Studio Formatting Options for an entire team

荒凉一梦 提交于 2019-12-20 16:31:27
问题 Different devs on our team have wildly different checkboxes here: and as a consequence Visual Studio keeps reformatting code and this really pollutes our commits. What I want is to have a single whatever ( .reg file or something) to run on each devs' computer so that these settings will be consistent. How can I do this? 回答1: With VS2017, .editorconfig files are taken into account and allow to override local preferences. Put it at the root of your projects solution (or even higher), under

How to set Python language specific tab spacing in Visual Studio Code?

匆匆过客 提交于 2019-12-20 16:16:03
问题 Using VSCode 1.9.0 with the (donjayamanne) Python 0.5.8 extension, is it possible to provide Python specific editor options? Or more generally speaking, is it possible to provide language specific tab spacing and replacement rules? For example, Python should be tab=4 spaces (replaced as spaces), and Ruby should be tab=2 spaces (replaced). Other languages tend to have their own opinions. However, I only see the general "editor.tabSize": 4, "editor.insertSpaces": true, options. I thought

Matlab code formatting similar to AStyle? [closed]

旧街凉风 提交于 2019-12-20 14:12:50
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . Is there any tool similar to AStyle to format matlab code in m-files? 回答1: In recent versions of MATLAB, you can use the "Smart Indent

Are there any lint tools for C and C++ that check formatting?

巧了我就是萌 提交于 2019-12-20 12:35:35
问题 I have a codebase that is touched by many people. While most people make an effort to keep the code nicely formatted (e.g. consistent indentation and use of braces), some don't, and even those that do can't always do it because we all use different editors, so settings like spaces vs. tabs are different. Is there any standard lint tool that checks that code is properly formatted, but doesn't actually change it (like indent but that returns only errors and warnings)? While this question could

Ruby code beautification, split long instructions on multiple lines

淺唱寂寞╮ 提交于 2019-12-20 11:01:36
问题 How can we write the following statement to improve readability? Promotion.joins(:category).where(["lft>=? and rgt<=?", c.lft, c.rgt]).joins(:shops).where(:promotions_per_shops => { :shop_id => shops_id }).count('id', :distinct => true) The following doesn't compile Promotion.joins(:category) .where(["lft>=? and rgt<=?", c.lft, c.rgt]) .joins(:shops) .where(:promotions_per_shops => { :shop_id => shops_id }) .count('id', :distinct => true) syntax error, unexpected '.', expecting kEND .where([