Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to custom code folding for Scala in intelliJ IDEA?

I have seen this blog: Custom code folding regions in IntelliJ

But it's useful for Java, it doesn't work on Scala.

like image 528
Guo Avatar asked May 18 '16 06:05

Guo


People also ask

How do I collapse code in IntelliJ?

Expand or collapse code elements To collapse or expand all code fragments, press Ctrl+Shift+NumPad - / Ctrl+Shift+NumPad + . IntelliJ IDEA collapses or expands all fragments within the selection, or, if nothing is selected, all fragments in the current file, for example, all methods in a file.

Does IntelliJ work with Scala?

To start working with Scala in IntelliJ IDEA you need to download and enable the Scala plugin. If you run IntelliJ IDEA for the first time, you can install the Scala plugin when IntelliJ IDEA suggests downloading featured plugins. Otherwise, you can use the Settings | Plugins page for the installation.

How do I create a Scala class in IntelliJ?

On the Project pane on the left, right-click src and select New => Scala class. If you don't see Scala class, right-click on HelloWorld and click on Add Framework Support…, select Scala and proceed. If you see Error: library is not specified, you can either click download button, or select the library path manually.

How do I convert Java to Scala in IntelliJ?

In the editor, type a name of a new code element and press Alt+Enter. From the list of intentions, select the one you need. Press Enter. IntelliJ IDEA lets you convert Java code into Scala. Copy your Java code (expression, method, class) and paste it into a Scala file.

How do I fold regions in IntelliJ IDEA?

Now, when you select the Custom folding regions option, IntelliJ IDEA will fold such regions when you open your file in the editor. JavaScript - language-specific code fragments in JavaScript and TypeScript

What is IntelliJ IntelliJ IDEA?

IntelliJ IDEA lets you use different Scala intention actions, convert your code from Java to Scala, and use different Scala templates while working in the IntelliJ IDEA editor. You can add different intentions for strings, perform different actions, and set a different format for multi-line strings.

How do I use live templates in IntelliJ IDEA for Scala?

IntelliJ IDEA displays the list of available Live templates for Scala. Select the one you need and press Enter. You can also define a new template or edit the existing one.


1 Answers

To make that work what I do is add a new line after

  //<editor-fold desc="Description">

and before too

  //</editor-fold>

so it code will look like

  //<editor-fold desc="Description">

  def save() = {
    //save
  }

  def findOne() = {
    //fineOne
  }

  //</editor-fold>

If code folding is still not available you can delete > from //<editor-fold desc="Description"> and add it again and it will work.

I think its a bug and that's the workaround that I'm doing.

like image 141
A0__oN Avatar answered Nov 15 '22 08:11

A0__oN