CotEditor icon indicating copy to clipboard operation
CotEditor copied to clipboard

[Feature Request] Auto-Indent Should Detect When Indentation Increase Needed

Open luxlogica opened this issue 8 years ago • 1 comments

The current 'Auto-Indent' feature merely keeps the same indentation as the previous line. It would be wonderful if it could detect when indentation should be increased, too.

It seems to me that currently the CotEditor parser only looks at the current line when determining context, but even with this limitation, there would be a number of situations where making the auto-indenting more intelligent would help the developer:

// HTML - if current line has open tag without matching closing tag, increase indentation:
<div>
    <h2>

// CSS/LESS - if current line ends with '{', increase indentation:
.my-class {
    attribute: 0;

// YAML - if current line ends with ':', increase indentation:
author:
  name: John Smith

This could be implemented as a syntax-based feature - i.e., in the syntax definition we could specify when to increase indentation by using line regexes.

This issue is related - but not the same - to #569.

luxlogica avatar Dec 30 '17 00:12 luxlogica

Thank you for the feedback.

As you pointed out, the current syntax parser and definition specification for CotEditor lack the concept to parse the tree structure of documents. And it is definitely needed to implement various features such as yours or block folding. Everything will be implemented little by little by spending my private development time. However, I'll put relatively high on my priority list.

1024jp avatar Jan 06 '18 06:01 1024jp