Commenting Out Code

Most programming languages support "comments", or regions of code which are ignored by the compiler/interpreter. jEdit has several commands which make commenting out code slightly easier.

Edit>Selection>Wing Comment (keyboard equivalent: Control-E Control-C) will enclose the selection with comment start and end strings. An example of C++ wing commented code looks like so:

/* Process *proc = Process::getThisProcess();
proc->getMainThread()->postMessage(msg);
proc->getThread("__gui")->sendPulse(P_WAKE_UP); */

The strings used for wing commenting can be changed on a mode-specific basis in the Utilities>Global Options dialog box, or on a buffer-specific basis using buffer-local properties. For example, placing the following in one of the first 10 lines of a buffer will change the wing comment strings to "(*" and "*)":

:commentStart=(*:commentEnd=*):

Edit>Selection>Box Comment (keyboard equivalent: Control-E Control-B) will enclose the selection with comment start and end strings, and places the box comment string at the start of each line. An example of C++ box commented code looks like so:

/* Process *proc = Process::getThisProcess();
* proc->getMainThread()->postMessage(msg);
* proc->getThread("__gui")->sendPulse(P_WAKE_UP); */

The strings used for box commenting can be changed on a mode-specific basis in the Utilities>Global Options dialog box, or on a buffer-specific basis using buffer-local properties. For example, placing the following in one of the first 10 lines of a buffer will change the box comment strings to "(*" and "*"), with "(-" placed at the start of each line:

:commentStart=(*:commentEnd=*):boxComment=(-:

Edit>Selection>Block Comment (keyboard equivalent: Control-E Control-K) will place the block comment character at the start of each line in the selection. An example of C++ block commented code looks like so:

// Process *proc = Process::getThisProcess();
// proc->getMainThread()->postMessage(msg);
// proc->getThread("__gui")->sendPulse(P_WAKE_UP);

The string used for block commenting can be changed on a mode-specific basis in the Utilities>Global Options dialog box, or on a buffer-specific basis using buffer-local properties. For example, placing the following in one of the first 10 lines of a buffer will change the block comment string to "--":

:blockComment=--: