code-formatting

Eclipse JavaScript formatter crazy (i.e: too much padding)

混江龙づ霸主 提交于 2019-12-03 14:23:22
I'm having trouble to get eclipse format my JavaScript well. In this first example, it behaves as expected (not the length of the second url): Whenever i have a longer url, eclipse goes crazy formatting my code and I get extra padding everywhere, like the example below: Why does the JavaScript formatter behaving like this, and how do I fix it? (Just in case: I have not installed any formatter plugin, I just use the default that comes with Eclipse Juno) atlanto The long url in the example affects "$.ajax(..." and "$(function()...". As for "$(function()...", the setting is in Preferences

How can I strip comments and doc strings from python source code? [closed]

浪子不回头ぞ 提交于 2019-12-03 14:17:54
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. Is there a program which I can run like this: py2py.py < orig.py > smaller.py Where orig.py contains python source code with comments and doc strings, and smaller.py contains identical, runnable source code but without the comments and doc strings? Code which originally looked like this: #/usr/bin/python """Do something blah blah... """ # Beware the frubnitz! def foo(it): """Foo it!""" print it # hmm? Would then look

Code-formatting: How to align multiline code to special characters?

蹲街弑〆低调 提交于 2019-12-03 13:36:38
问题 Is IDEA or one of its plugins capable of aligning code to special characters? I mean so that the code Map( 'name -> "Peter", 'age -> 27, 'company -> "Foobar" ) is transformed to Map( 'name -> "Peter", 'age -> 27, 'company -> "Foobar" ) Example2: execute("x", true, 27) execute("foobar", false, 0) transformed to execute("x" , true , 27) execute("foobar", false, 0 ) 回答1: You can align case statements, however: value match { case s: String => Some(java.lang.Long.parseLong(s)) case bi: BigInt =>

Can Uncrustify be prevented from modifying certain sections of code?

若如初见. 提交于 2019-12-03 11:41:01
问题 Uncrustify is great, and does an excellent job of tidying code. However, I have some C code within a file that I don't want Uncrustify to change. Is there any way I can prevent Uncrustify from touching this, maybe by putting specific tags in comments around the code or something? 回答1: /* *INDENT-OFF* */ int i = 0; // No uncrustify action here /* *INDENT-ON* */ 来源: https://stackoverflow.com/questions/15097501/can-uncrustify-be-prevented-from-modifying-certain-sections-of-code

Autoindent on Sublime Text

主宰稳场 提交于 2019-12-03 11:14:39
问题 Are there any command/shortcut to auto-indent all my code on the page at once on Sublime Text 3? e.g: On NetBeans I can do this with Alt + Shift + F . 回答1: That's quite simple in Sublime. Just Ctrl+Shift+P (to open tools pallet), type reindent , and pick Indentation: Reindent Lines . It should reindent all the file you are in, just remember to save before running the command, or it may not appear. 回答2: Auto-indenting on Sublime Text 3 - "Key Bindings" Just add this binding to your "Key

How to config intellij-idea not format some part of the code?

天涯浪子 提交于 2019-12-03 10:35:20
问题 In a html file, there is some code used custom template-language: <script type="text/javascript"> function ($scope, JsRoutes) { $scope.rows = [ ${"#{list rows, as: 'row', separator: ','}"} { #{list fieldConfigs, as: 'f', separator: ','} ${f.name} : ${'$'}{row.${f.name}.toJson()}#{/list} } ${'#{/list}'} ] } </script> Is it possible to configure intellij-idea not to format it(but format the other part of the document)? Since idea will make it hard to read after formatting: <script type="text

How do I align/format code in Android Studio?

北慕城南 提交于 2019-12-03 10:31:43
Is there a way/shortcut/built-in feature that can align code for operands, like '=' signs? For example, there is a XAlign for Xcode ( https://github.com/qfish/XAlign ), allowing the user to select code that needs to be aligned and use a shortcut to align it automatically. There is a Fields Group feature in Android Studio which can "Align in columns", but it does not work for code that is already written. Jorgesys Indent code in Android Studio: Windows Ctrl + Alt + L Mac: Option + Command + L Syed Atir Mohiuddin In Eclipse which comes with Android Studio Bundle, the shortcut key is as follows

indent python file (with pydev) in eclipse

寵の児 提交于 2019-12-03 10:31:20
I'm a newbie in eclipse. I want to indent all the lines of my code and formatting the open file by pressing a shortcut or something like that... I know the CTRL+SHIFT+F (as it actually doesn't work in pydev!!) I've been searching for hours with no success. Is there any way to do that in eclipse. kind of like CTRL+K,D in visual studio, which formats and indents all the source code lines automatically? I ... don't think this question makes sense. Indentation is syntax in Python. It doesn't make sense to have your IDE auto-indent your code. If it's not indented properly already, it doesn't work,

Notepad++/Eclipse sql code auto-indent option?

大城市里の小女人 提交于 2019-12-03 10:27:01
问题 DDL gets especially ugly. Is there any option of SQL auto-indenting for Notepad++? I've tried to do it in Eclipse, but the code doesn't react to auto-indent. 回答1: Yes, there is a free/open-source T-SQL formatting plugin for Notepad++, called "Poor Man's T-SQL Formatter". It is available in the NPP "Plugin Manager" plugin list (gets updated every once in a while automatically), and is also available for manually downloading/installing from here: http://www.architectshack.com

Eclipse: Lining up function arguments vertically

半城伤御伤魂 提交于 2019-12-03 09:40:59
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? Follow these steps to achieve what you want: Open the preferences dialog (located in Windows -> Preferences on Windows/Linux or in the Eclipse menu on Mac). Go to