Working with comments

The WL Plugin provides many features for working with comments and one of the things you never have to do is manually typing (, *, *, and ) to create a comment. You can use Ctrl+/ or Ctrl+Shift+/ to create a new empty comment where the cursor is already inside. The difference between the two shortcuts is subtle but important

  • The first shortcut will create a new comment on an empty line. On a line that contains already code or if you have selected a portion of code, this shortcut will comment out the line(s).
  • The second shortcut will create an empty comment even, when you are in the middle of a line that contains code. This is helpful if you want to add a comment to a function parameter or directly after an expression.

Completion inside comments

Basic function and word completion works inside comments. If you have an empty comment (**) with the cursor in the middle, and you press Ctrl+Space, then the plugin will provide you with completion for (1) sectioning comments like (* ::Subsection *) and (2) tag comments like (* :Author: *).

Sectioning comments must always consist of two lines like this:

(* ::Section:: *)
(* This is the section title *)

If you follow this rule then the sections in your package will be rendered correctly when you open it in Mathematica.

Folding sections

Using sectioning comments to document and divide your code into structural parts has two advantages. First, users that view your package in the Mathematica front-end will see the blocks as separated cells with title-text. More important, if you use sectioning comments consistently, you can fold the contents inside IDEA.

The plugin will respect the hierarchy, which means folding a section will close all code between its start and the next section including all sub-sections that are in between. In this way you can create a foldable outline of your package, and the IDE will present a closed section with its title like this:

section comment

The small + sign on the left side indicates that this portion can be expanded.


  • Without any text-selection, you can always press Ctrl+Shift+/ to get a new, empty (**) with the cursor inside.
  • Without any text-selection Ctrl+/ will comment out the current line if there‚Äôs something on it or create a new comment on an empty line.
  • With text selected, Ctrl+/ will comment out the lines that span the text and Ctrl+Shift+/ will comment out exactly your selection. Please note that you can easily select bigger code constructs.
  • Inside a comment, Ctrl + Shift+ Enter will jump to the next line and create a new comment with the cursor inside.
  • You can autocomplete function names in comments with Ctrl+Space. In an empty comment (**) with the cursor inside, Ctrl+Space will suggest all the styling directives like ::Section::