madflow / flow-netbeans-markdown

Markdown file support for the NetBeans IDE
MIT License
279 stars 40 forks source link

Add smart indentation in editor #112

Open nmatt opened 8 years ago

nmatt commented 8 years ago

Smart indentation support for lists etc. would be nice. More specifically:

  1. When a new line is created (Insert Newline, Split Line, Start New Line), copy the indentation from the previous line if it contains non-whitespace characters.
  2. When the previous line only contains whitespace characters, unindent to the column of the first non-whitespace character on the first previous line where that character has less indentation.
  3. When the previous line is the first line of a list item, add additional indentation up to the column of the first non-whitespace character (if any, else the end-of-line position) following the list marker.
  4. When at the start of a paragraph after a list paragraph, let the Tab key generate that same indent (creating a continuation list paragraph).
  5. When the previous line is the first line of a blockquote, copy the indentation including the > up to the column of the first non-whitespace character (if any, else the end-of-line position) following the >.

Example for 1:

This is a regular line.

    This is a code block; if I press Enter here
    the result should be this.

    This is a code block; if I press Enter here
instead of this.

Example for 2:

1.  This is a list paragraph
    spanning two lines.

        This is a nested code block; if I press Enter twice here,

    the result should be this.

instead of this.

Example for 3:

1.  This is the first line of a list paragraph; if I press Enter here
    the result should be this.

1.  This is the first line of a list paragraph; if I press Enter here
instead of this.

Example for 4:

* This is the first paragraph of a list item,
  spanning two lines. If I press Enter twice and then Tab, the result should be:

  Like this, i.e. a second paragraph within the list item.

    ...instead of this, an indentation using the tab width.

Example for 5:

>  This is the first line of a blockquote; if I press Enter here
>  the result should be this.

>  This is the first line of a blockquote; if I press Enter here
instead of this.