InodeLabs/fern
1
14
Fork
You've already forked fern
2

Support Tabs for Indentation, Spaces for Alignment in editor #3

Closed
opened 2026年03月25日 18:10:57 +01:00 by bugwhisperer · 0 comments

Summary

This feature will support the "indent with tabs, align with spaces" principle/convention (used by gofmt and many style guides). Files would look correct at any tab-width setting whilst keeping the flexibility to work in spaces-only environments. Auto-indent would reduce friction for heavily indented code/text.

Conditions of Satisfaction

  • Config changes
    • expand_tabs (bool, default false): when false, Tab inserts a literal \t; when true, Tab inserts shift_width spaces.
    • shift_width config (int, default 4, range 1–16): number of spaces inserted per Tab press when expand_tabs = true. Existing tab_spaces retains its meaning as the visual column-width of \t in view/normal mode.
  • Tab display expansion: during the highlight pass, \t characters are expanded to spaces (tab-stop math) so that chroma colouring and line-wrapping see consistent column widths. Edit-mode tab display continues to follow terminal tab stops (textarea widget limitation).
  • Auto-indent on Enter / o / O: when the user opens a new line, leading whitespace from the current line is copied to the new line, placing the cursor after the indentation. Works with both tab and space indentation; reuses the existing lineIndent() helper.
  • :TabsToSpaces command / "Convert Tabs to Spaces" palette entry: replaces every \t in the active buffer with tab_spaces spaces and marks the file modified.
  • Both new config keys should be vault overridable (following the same pattern as tab_spaces).

External Resources

N/A

## Summary This feature will support the "indent with tabs, align with spaces" principle/convention (used by `gofmt` and many style guides). Files would look correct at any tab-width setting whilst keeping the flexibility to work in spaces-only environments. Auto-indent would reduce friction for heavily indented code/text. ## Conditions of Satisfaction - [x] **Config changes** - [x] `expand_tabs` (bool, default `false`): when `false`, Tab inserts a literal `\t`; when `true`, Tab inserts `shift_width` spaces. - [x] `shift_width` config (int, default 4, range 1–16): number of spaces inserted per Tab press when `expand_tabs = true`. Existing `tab_spaces` retains its meaning as the visual column-width of `\t` in view/normal mode. - [x] **Tab display expansion**: during the highlight pass, `\t` characters are expanded to spaces (tab-stop math) so that chroma colouring and line-wrapping see consistent column widths. Edit-mode tab display continues to follow terminal tab stops (textarea widget limitation). - [x] **Auto-indent on Enter / `o` / `O`**: when the user opens a new line, leading whitespace from the current line is copied to the new line, placing the cursor after the indentation. Works with both tab and space indentation; reuses the existing `lineIndent()` helper. - [x] **`:TabsToSpaces` command / "Convert Tabs to Spaces" palette entry**: replaces every `\t` in the active buffer with `tab_spaces` spaces and marks the file modified. - [x] Both new config keys should be vault overridable (following the same pattern as `tab_spaces`). ## External Resources N/A
Sign in to join this conversation.
No Branch/Tag specified
main
v1.5.6
v1.5.5
v1.5.4
v1.5.3
v1.5.2
v1.5.1
v1.5.0
v1.4.1
v1.4.0
v1.3.9
v1.3.8
v1.3.7
v1.3.6
v1.3.5
v1.3.4
v1.3.3
v1.3.2
v1.3.1
v1.3.0
v1.2.1
v1.2.0
v1.1.0-beta
v1.0.3-beta
v1.0.2-beta
v1.0.1-beta
v1.0.0-beta
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.8.3
v0.8.2
v0.8.1
v0.8.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
InodeLabs/fern#3
Reference in a new issue
InodeLabs/fern
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?