jEdit in hard word-wrap mode: insert comment character automatically?

200 views Asked by At

Probably quite a niche question, but I believe in the power of a big community: Is it possible to set up jEdit in way, that it automatically inserts a comment character (//, #, ... depending on the edit mode) at the beginning of a new line, if the line before the wrap was a comment?

Sample:

# This is a comment spanning multiple lines. If I continue to type here, it
# wraps around automatically, but I have to manually add a `#` to each line. 

If I continue to type after the . the third line should start with the # automatically. I searched in the plugin repository but could not find anything related.

Background: jEdit has the concepct of soft and hard wrap. While soft wrap only breaks lines visually at a character limit, it does not insert line breaks in the file. Hard wrap on the other hand inserts \n into the file at the desired character count.

1

There are 1 answers

0
AhLeung On

This is not exactly what you want: I use the macros Enter_with_Prefix.bsh to automatically insert the prefix (e.g., #, //) at the beginning of the new line.

Description copied from Enter_with_Prefix.bsh:

  • Enter_with_Prefix.bsh - a Beanshell macro for jEdit
  • that starts a new line continuing any recognized
  • sequence that started the previous. For example,
  • if the previous line beings with "1." the next will
  • be prefixed with "2.". It supports alpha lists (a., b., etc...),
  • bullet lists (+, =, *, etc..), comments, Javadocs,
  • Java import statements, e-mail replies (>, |, :),
  • and is easy to extend with new sequence types. Suggested
  • shortcut for this macro is S+ENTER (SHIFT+ENTER).