title |
---|
17. Commenter |
A commenter enables the user to comment-out a line of code at the cursor or selected code automatically.
The Commenter
defines support for Code | Comment with Line Comment and Code | Comment with Block Comment actions.
- bullet list {:toc}
The commenter for Simple Language defines the line comment prefix as #
.
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCommenter.java %}
The SimpleCommenter
implementation is registered in the plugin configuration file using the com.intellij.lang.commenter
extension point.
<extensions defaultExtensionNs="com.intellij">
<lang.commenter language="Simple" implementationClass="org.intellij.sdk.language.SimpleCommenter"/>
</extensions>
Open the example Simple Language properties file in the IDE Development Instance.
Place the cursor at the website
line.
Select Code | Comment with Line Comment.
The line is converted to a comment.
Select Code | Comment with Line Comment again, and the comment is converted back to active code.