code-formatting

Turn off Eclipse formatter for selected code area? [duplicate]

淺唱寂寞╮ 提交于 2019-11-27 15:42:49
问题 This question already has an answer here: How to turn off the Eclipse code formatter for certain sections of Java code? 12 answers When I ctrl + shift + f up the project code, its doing its job just fine, everywhere. But its messing the CSS, specially those filter parts and adding bunch of spaces. Also how do I specify some portion of Java code to not be formated by that command ? 回答1: To prevent specific portions of Java code from being formatted, go to "Window > Preferences > Java > Code

Python “best formatting practice” for lists, dictionary, etc

白昼怎懂夜的黑 提交于 2019-11-27 14:24:33
问题 I have been looking over the Python documentation for code formatting best practice for large lists and dictionaries, for example, something = {'foo' : 'bar', 'foo2' : 'bar2', 'foo3' : 'bar3'..... 200 chars wide, etc..} or something = {'foo' : 'bar', 'foo2' : 'bar2', 'foo3' : 'bar3', ... } or something = { 'foo' : 'bar', 'foo2' : 'bar2', 'foo3' : 'bar3', ... } How do I handle deep nesting of lists/dictionaries? 回答1: My preferred way is: something = {'foo': 'bar', 'foo2': 'bar2', 'foo3': 'bar3

Split Ruby regex over multiple lines

时光毁灭记忆、已成空白 提交于 2019-11-27 12:38:15
问题 This might not be quite the question you're expecting! I don't want a regex that will match over line-breaks; instead, I want to write a long regex that, for readability, I'd like to split onto multiple lines of code. Something like: "bar" =~ /(foo| bar)/ # Doesn't work! # => nil. Would like => 0 Can it be done? 回答1: You need to use the /x modifier, which enables free-spacing mode. In your case: "bar" =~ /(foo| bar)/x 回答2: Using %r with the x option is the prefered way to do this. See this

In Emacs, how to line up equals signs in a series of initialization statements?

耗尽温柔 提交于 2019-11-27 11:10:49
问题 I saw this somewhere, but cannot find it now. Is there a built-in function in emacs, or does someone have elisp, to line up all the equals signs in a series of inititialization statments in cc-mode? Before: int t=9; Graphics g = new Graphics(); List<String> list = new List<String>(); After: int t = 9; Graphics g = new Graphics(); List<String> list = new List<String>(); 回答1: Use M-x align-regexp (here, M-x align-regexp RET = RET ). You can also add an "alignment rule" to the variable align

SQL string formatter [closed]

馋奶兔 提交于 2019-11-27 11:05:46
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Does anyone know of a program, a utility, or some programmatic library, preferably for Linux, that takes an unformatted SQL string and pretty prints it? For example I would like the following select * from users where name = 'Paul' be changed to something like this select * from users where name = 'Paul' The

JavaScript Chart.js - Custom data formatting to display on tooltip

只愿长相守 提交于 2019-11-27 09:58:05
问题 I have looked at various documentation and similar questions on here, but cannot seem to find the particular solution. Apologies if I have missed anything obvious or have repeated this question! As a bit of background info, I have implemented 4 graphs using the Chart.js plugin and passed in the required data using PHP from a database. This is all working correctly and is fine. My problem is I need to display the data in the tooltips as formatted data aka. as numeric with %. As an example, one

Is it possible to auto-format your code in Dreamweaver?

守給你的承諾、 提交于 2019-11-27 09:48:46
问题 Is it possible to auto-format your code in Dreamweaver like in Visual Studio (ctrl+k+d) 回答1: A quick Google search turns up these two possibilities: Commands > Apply Formatting Commands > Clean up HTML 回答2: Commands > Apply Source Formatting. Works a treat. 回答3: For the 2017 CC release this has been moved (after many years of habit development). Find it now at: Edit > Code > Apply Source Formatting. It may be prudent to set up a keyboard shortcut if this is something you'll need regularly.

Why does HTML5 recommend putting the code element inside pre?

[亡魂溺海] 提交于 2019-11-27 09:39:09
问题 The HTML5 documentation recommends putting the code element inside the pre element, but I don't understand how this is better or more semantic than just using the code element and CSS. In their own example: <pre><code class="language-pascal">var i: Integer; begin i := 1; end.</code></pre> Could also be written (Making some assumptions about the browser's defaults for pre ): <style> code { display: block; white-space: pre; } </style> … <code class="language-pascal">var i: Integer; begin i := 1

Is it possible to format C++ code with VIM?

你说的曾经没有我的故事 提交于 2019-11-27 09:38:18
问题 I am rather new to VIM. I got some source code and this is a mess. At a first sight I would like at least to get a clear and organised view of the code, so I like to get it rightly formatted, I mean indented depending on the depth of the functions and so. I wonder if it can be done with VIM, and otherwise which other commandline tools for that can you recommend. Thanks 回答1: While vim is a true Swiss-knife I still prefer external tools for some jobs. This approach is some times much more

How do you format code on save in VS Code

一个人想着一个人 提交于 2019-11-27 09:18:01
问题 I would like to automatically format TypeScript code using the build-in formatter when I save a file in Visual Studio Code. I'm aware of the following options, but none of them is good enough: Format manually Shift + Alt + F Format on type "editor.formatOnType": true It formats the line when you press enter. Unfortunatelly, it leaves it unformatted when you mouse-click another line or press up/down arrow. Use existing extension I tried this one, but it does not seem to work too well. Use