How to fold custom region in CLion through comments? - ide

I read this:
https://www.jetbrains.com/clion/help/folding-and-expanding-custom-blocks.html
and tried following this link:
https://www.jetbrains.com/clion/help/Folding_Custom_Regions_with_Line_Comments.html
but it appears to be broken, since it redirects to "Meet CLion" page.
How do I define custom folding regions in CLion using comments?

CLion is based on IntelliJ IDEA, and thus supports multiple ways, including:
//region Description
//endregion
and
//<editor-fold desc="Description">
//</editor-fold>
These can be easily accessed by selecting the code you wish to wrap in a region, and hitting Ctrl+Alt+T. You can alternatively access it by clicking Code > Surround with... in the menu bar.

Related

'fold up' sections of code - like when you close a control structure

I remember that there was a tag which made it possible to fold multiple lines.
e.g. like if you would fold down a for loop:
to
Is there a tag which makes this possible? Or is this an IDE specific tag?
Depends on the language and ide/editor.
In C# there are #region's that can be used for this. In some editors you can enable folding on all scopes (brackets). In some editors you can teach the editor to enable folding on comments with brackets in them ("//{" "//}").
In most cases this is an editor option that has to be enabled and configured.
What editor are you using? (and what language is this, JavaScript?)
For netbeans checkout the following: (You don't need to go past the first one)
http://wiki.netbeans.org/FaqCustomCodeFolds - Manual method
http://wiki.netbeans.org/SurroundWithCodeFolding - Code Template
https://ui.netbeans.org/docs/ui/code_folding/cf_uispec.html#custom - Talks about the how they work.
Example from first article:
// <editor-fold>
Your code goes here...
// </editor-fold>

Atom autoclose-html how to force inline closing tags

Brand new to Atom. I see that I can force some html tags to close inline using the autoclose-html package. However, when I populate the list with tags to close inline, they are still closing on a separate line. How should the list be formatted? I see the defaults as
default: ['title', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']
And so I first tried adding ...'p', 'span'] to the list, and it did not work. I then found a list in autoclose-html.coffee and added the same, to no avail. What am I doing wrong?
The way I did this (Mac OS - should be same for other OS's):
Bring up Atom Settings (Atom menu --> Preferences)
Select Packages
Select autoclose-html Settings
Select View Code
Expand the lib folder
Select configuration.coffee
Make your changes in there and save the file.
Restart Atom
All done!
I don't know whether you have fix this issue. I just work it out.
It's nothing about this package, it's handled by atom's html-language plugin. Just open Atom->Snippets and add the following codes:
Sorry the preview looks terrible when I post the code as text. So I post a image here.

switching between languages in same file

I recently attended a user group meeting where the IntelliJ representative was demonstrating version 13.
He demonstrated how to switch the code completion view of a file. I do not exactly remember what the file extension of this particular file was, probably java.
The concept was that if the file is html with embedded javascript he could then switch the code completion between html and javascript with a shortcut. If he says treat the file as html then all code in file was treated for code completion purposes as html, and vice versa for javascript.
Does anybody know what shortcut he might have been using to enable the language switch?
Sounds like you may be referring to the IntelliLang feature. IntelliJ IDEA can be aware of other languages embedded within a file.
A simple example is in an HTML file that has CSS and JavaScript.
Notice when I am inside the HTML markup:
or inside an HTML element:
The code complete shows HTML completion options. However, when I am inside the style attribute, I get CSS code completion:
I also get CSS code completion if I am inside a <style> element. So even though I am in an HTML file, I see CSS code completion because of my location.
Same case with JavaScript. When I invoke code completion inside a <script> element, I get JavaScript completion, even though I am in an HTML file.
Anytime IntelliJ IDEA can determine that another embedded language is present, it provides, via IntelliLang, the appropriate syntax highlighting, error highlighting, and code completion. The same holds true for Java. Notice here that IDEA knows the method I am competing takes an SQL statement and therefore highlights the String value using SQL highlighting, and provides SQL code completion:
So even though I am in a .java file, I get SQL code completion. The reason is that IntelliLang comes pre-configured knowing the embedded language of some methods. You modify them, or add more, in File > Settings > [Project Settings] > Language Injections.
In addition, you can use an annotation to tell IntelliJ IDEA (as well as developers looking at the code) that a String must be valid in a particular language. For example, I can annotate a String field, variable, or parameter, to indicate it must be valid HTML:
Notice I get HTML syntax highlighting, HTML code completions, and the CSS color shows in the left gutter. If I annotate a method parameter, then any time I call the method, I get the appropriate syntax highlighting, code completion, and error/warning highlighting:
The #Language annotation is inside the annotations.jar that is contained in the redist directory inside the IntelliJ IDEA installation directory. It is also available in maven central, or IDEA will offer to attach it as a Library if you use the annotation without it being attached.
IntelliLang and the #Language annotation supports a large number of languages. Just use code Completion inside the quotes after typing #Language("") to see a list. (Inline search works in the list as well.) One of the most useful is Regexp. For example, if you have a method that expects the string passed in to be a valid Regular Expression, annotating it as such will give anyone that calls it Regex code completion and error highlighting if they are passing in an invalid Regex pattern. Even for developers using other IDEs it is useful as a form of documentation.
As for a shortcut to change the the language on the fly for code completion, the only thing I can think that you might be referring to is the "Inject Language" intention. If I am entering a String value, and I bring up the quick-fix/intention menu via Alt+Enter, I am given an option to inject a language:
If I select that, IntelliJ IDEA will ask me what language I want to use:
After making my selection, IntelliJ IDEA will give me temporary language injection (including code completion) for the selected language.
It also gives me an option to add the #Language annotation for permanent injection.
To the best of my knowledge (as a 10 year IntelliJ IDEA user) that is the only way to switch code completion language types. So hopefully that is what you are looking for. To me, IntelliLang is one of the coolest features in IntelliJ. (It actually started as a third party plug-in and JetBrains then absorbed it into the product.)

IntelliJ wrapping comments in Javascript

Is it possible to wrap long comment lines in IntelliJ in javascript files? I have turned on line wrapping as shown in the settings below, but when I do a code reformat, it doesn't wrap the line.
It's not supported yet on code reformatting, added a new feature request, please vote.
I'm using IntelliJ 14 on a Mac, which has a Fill Paragraph command. Access it via the awesome universal Command-Shift-A action search feature. Works like a charm!

Creating Dijit > Editor > Plugins

I have been googling this subject for hours. Does anyone have an examples of a custom plugin being deployed in Dijit's Editor. I'd be really interested to look at it because I have been following this without much success and of the few examples that exist out there none of them come with working examples :(
(I'm looking to create a pulldown menu like the one for font selection)
There's no difference between a custom plugin and a "builtin" plugin, so I suggest just looking at a small builtin example like TabIndent, and then move on to the font selection itself.