The WL Plugin provides many features for working with comments and one of the things you never have to do is
) to create a comment.
You can use
/ 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
Space, then the plugin will
provide you with completion for (1) sectioning comments like
(* ::Subsection *) and (2) tag comments
(* :Author: *).
Sectioning comments must always consist of two lines like this:
If you follow this rule then the sections in your package will be rendered correctly when you open it in Mathematica.
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:
+ sign on the left side indicates that this portion can be expanded.
- Without any text-selection, you can always press
/to get a new, empty
(**)with the cursor inside.
- Without any text-selection
/will comment out the current line if there’s something on it or create a new comment on an empty line.
- With text selected,
/will comment out the lines that span the text and
/will comment out exactly your selection. Please note that you can easily select bigger code constructs.
- Inside a comment,
Enterwill jump to the next line and create a new comment with the cursor inside.
- You can autocomplete function names in comments with
Space. In an empty comment
(**)with the cursor inside,
Spacewill suggest all the styling directives like