Is there an extension to beautify a Processing sketch? - formatting

I haven't used Processing in many years. I am copying some old code into Processing and it is pasting onto one line. Is there a beautify extension for Processing 3? Have looked and can't find.

What you're talking about is called auto-formatting, not beautifying.
The Processing editor includes an auto-formatter. Just go to Edit > Auto-Format, or press ctrl+t to do it from the keyboard.
Alternatively, most code IDEs like eclipse also include auto-formatters.
However, if everything is on one line, it sounds like you're dealing with an issue copying the newline character. This can happen if you copy something from one OS to another, for example. You might be able to google for a tool that fixes this problem, but it might be simpler to just put in the line breaks manually and then use the auto-formatter to handle the indentation for you.

Related

Auto fold code on open file by a certain comment in vscode

Is there any extension available that has the ability to automatically fold possible code fragments like a switch when there is a certain comment in the appropriate line?
I think that one is exactly what you are looking for:
https://marketplace.visualstudio.com/items?itemName=bobmagicii.autofoldyeah
But! I never tried it

Can I make IntelliJ IDEAs auto indent ignore previous lines?

Auto-indenting in IntelliJ IDEA seems to automatically takes lines previous to the selection in to consideration. This means that if the indentation is incorrect in the part of the file you're working on (e.g., 3 or 5 spaces where there should be 4, or even worse, a mix of tabs and spaces) it's annoyingly difficult to add correctly indented code.
Both new lines I'm adding and lines I use auto-indent on because I've changed them anyway get messed up like this. Since the file I'm working on is being worked on by someone else as well on another branch, I really don't want to modify over a third of the file just to indent everything correctly, but I would still like the lines that I'm actually modifying/adding to be correct - I don't see any reason to perpetuate the error when it's not necessary.
Currently the best mechanism for fixing it I've found is to manually do the spaces on a line and go from there, but it's really quite annoying, especially since I can't use the tab key or IntelliJ will immediately move to the incorrect indentation. It's barely better than copy/pasting the text to Sublime Text, fix the indentation there and paste it back without formatting.
My apologies if this has already been asked, I've tried to search for it, but it's very hard to search for this as there's so many auto-indent questions.
IntelliJ IDEA recently added a feature (in v14 or 1v4.1 if I recall) where it will detect indentation that is different from your settings. It will honor those indentations (in order to keep the file consistent). Usually as soon as you start editing the file, you get a banner, although that can be turned off. The banner looks like this:
This allows you to modify this setting on a per file basis, or turn it off completely (i.e. the "Show Settings" option).
I suspect this feature is what is causing you the issue. I am not sure how it handles a case where a file has mixed indentation (e.g. most of the file is 4, but some sections are 3 or 5 spaces). You can try turning this feature off in Settings > Editor > Code Style > "Detect and use existing file indents for editing"

Is there a text editor or ide that will do this things?

Is there a text editor that will let me shade certain code blocks with specific colors so I can easily find them later? Bookmarks are great, but I also wanted to shade with the same color all code blocks which are somehow related to each other.
and
When my current text editors autocreate curly braces or parentheses for me and I type what I want in between them, are there any that let me either jump to the end of the line to put a semicolon there, or "return" to type the next line, or do I always have to use the arrow key to get out of the curly braces? Perhaps there is a shortcut I'm missing?
I think about every code editor, including Notepad++, has bookmarks. If you're looking for a more complete IDE, it probably depends on the language you're using. For .NET languages that is Visual Studio, but you probably would have known that. For PHP, Javascript and HTML/CSS, you can use Netbeans for PHP. Netbeans is also available for Java. It is a rich editor, and I think one of the best free general purpose IDE's available.
Marking pieces of code in colors is unknown to me. I've never seen an editor that supports this. You would also need a project in which to store the start and end points of these blocks, unless you would save them as comments or so in the file itself.
Visual Studio knows regions which you can define by a start tag and an end tag. You can collapse and unfold an entire region at once, making it quite easy to navigate through larger files.
But these regions are actually part of the code file, so you cannot use this for any file, because those region markers will probably make the file invalid.
I'm still wondering why any other shortcut key would be easier or more convenient than 'arrow down'..

Sublime text 2 prints wrong comment block on shortcut

For some time now, when i hit cmd-/ (mac) in .php files it prints the comments for html,
and not for php.
so it does instead of //
the format is set to PHP, and it shows 'php' on the bottom right of the editor,
also all the syntax highlighting is fine.
any idea?
thanks :)
T
Sublime is decent, I prefer notepad++ and brackets for development. For your issue, uninstall than install Sublime in default, see if it works. If it does work, and you have custom plugins for it, add one at a time and test. To see what is causing the problem. If nothing is causing the problem and you have everything set to how you had it prior. I am guessing that some form of data corruption occured or the shortcut for a comment in php is mixed up with the comment in html. The text editor shouldn't be treating a completely different language as another. I hope this helped.
What commenting is done is based on the scoping rules. I'm not a PHP programmer so I might get some of the details wrong, but you should get the general idea. If I understand correctly, PHP files consist of a mix of HTML elements and PHP code blocks. ST allows for languages to be "embedded" within another file type (in this case, embedding HTML in the PHP syntax). If the cursor is in an html region, it will use HTML commenting. If it is a PHP region, it will use PHP commenting. I know there are some issues with edge cases, but try moving the cursor into the actual PHP code block, then using the comment command. You could probably find a modified language file that will just treat everything as PHP if you want.
To check the scopes begin applied, you can use the ScopeHunter plugin. Alternatively, you can use the ctrl+alt+shift+p in windows and linux or cmd+alt+p in osx to display the scope in the status bar.
I hope that helps clarify how commenting works. How you choose to actually "solve" this is up to you though, as it's more of a personal preference thing.

Is there an IDE or plugin which allows separation of code from layout?

I'm looking for something like CSS for code. Does it exist either in an IDE, or as a plugin?
The compiler often doesn't care how many more spaces or tabs or newlines you have between tokens in your code, but people do care.
I want to specify in my "style sheet" that braces always live on a seperate line, commas are always followed by spaces, and spaces always surround operators.
Somebody else could then take my code and in their style sheet, specify that no unnecessary spaces should be visible, braces should always be on the same line as their predecessor, and functions should always be separated by 3 line breaks. But the code itself should not actually change.
Is there such a tool?
I don't think such a thing exists, the best solution is to have a custom style for local coding (most IDE's allow this) and then use a tool to reformat your source code (like Jalopy for Java) when you commit it centrally.
That way you have something that's common centrally, but can still style how you want locally.
I don't know of any tool that can arbitrarily apply a style to code without actually modifying the text itself. Since you need to edit the code, that seems impractical.
This is called code formatting and if you google "code formatter" and your language of choice you should get a list of available options.
Try some eclipse based IDE (Aptana) or eclipse itsefl and and from there you can configure how the formatting works :)