Skip to content

add indentation guide - #116

Draft
keith-hall wants to merge 1 commit into
sublimetext-io:masterfrom
forkeith:indentation
Draft

add indentation guide#116
keith-hall wants to merge 1 commit into
sublimetext-io:masterfrom
forkeith:indentation

Conversation

@keith-hall

Copy link
Copy Markdown
Contributor

Fixes #107

@FichteFoll FichteFoll left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a draft PR, I just took a very brief look at what you were going for here and added a few comments


Sublime Text can perform automatic indentation when you type.
It can also reindent text according to the indentation rules on demand.
Note that it will not perform auto-formatting, like adding newlines or adjusting spaces around parenthesis and the like. You would need an external tool or plugin for that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider adding more line breaks at positions that make sense semantically. I assume you're still in the process of revising this, however, since some sections already use shorter lines.

@michaelblyons michaelblyons Dec 26, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plural is "parentheses."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Note that it will not perform auto-formatting, like adding newlines or adjusting spaces around parenthesis and the like. You would need an external tool or plugin for that.
Note that it will not perform auto-formatting,
like adding newlines or adjusting spaces around parentheses.
You would need an external tool or plugin for that.

Mostly fixing the plural of "parenthesis," but also breaking into phrases like the contributing docs ask.

This is also potentially useful for incomplete statements (split over multiple lines), for example some languages require statements to be terminated with a semi-colon `;`, and visually indenting them makes it more readable.
```js
a.b().c.d.e.f
.g().h.i();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a bad example here because this exact use case breaks when a statement is broken over more than just two lines. A better idea would be to cover C-style bracket-less if statements.

Indentation rules are defined using metadata files.
However, because metadata for indentation rules is complicated and
is commonly required by packages which add syntax definitions,
it's discussed separately in this page

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general style thing, I tend to refrain from using shortenings like "it's" in prose. But this is an optional thing and just an FYI. I will most likely do a full pass on the page once it's ready for a more detailed review and commit it directly.


## Indentation when pressing <kbd>Enter</kbd>

The main aspect of auto indentation increasing the indent level occurs when pressing <kbd>Enter</kbd>, anywhere on a line.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a custom tag for key bindings. Usage is <Key k="enter" />.

@michaelblyons michaelblyons left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Learned some things, reading this. I almost want a set of flow charts now. 😅


Sublime Text can perform automatic indentation when you type.
It can also reindent text according to the indentation rules on demand.
Note that it will not perform auto-formatting, like adding newlines or adjusting spaces around parenthesis and the like. You would need an external tool or plugin for that.

@michaelblyons michaelblyons Dec 26, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plural is "parentheses."


### other built-ins

The user preference `indent_to_bracket` adds whitespace up to the first open bracket when indenting. It also affects unindenting too, the close paren is placed in the column after the open paren.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The user preference `indent_to_bracket` adds whitespace up to the first open bracket when indenting. It also affects unindenting too, the close paren is placed in the column after the open paren.
The user preference `indent_to_bracket` adds whitespace up to the first open bracket when indenting. It also affects unindenting, too; the close paren is placed in the column after the open paren.

@michaelblyons

Copy link
Copy Markdown
Contributor

I tried to send someone to the community docs for this info and realized this PR wasn't incorporated yet. 😅

@keith-hall

Copy link
Copy Markdown
Contributor Author

ah sorry, I never really got round to finishing, so little time and more interesting and beneficial (to me) things to do...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add page(s) for indentation

3 participants