Line Ending Controller
approvedby anse
Control line ending format (LF/CRLF) per file or per folder. Prevent Obsidian from silently converting CRLF to LF. - This plugin has not been manually reviewed by Obsidian staff.
Line Ending Controller
Control line ending format (LF / CRLF) per file or per folder in Obsidian.
đ This plugin supports English and įŽäŊ䏿 â automatically follows Obsidian's display language.
đ ä¸æææĄŖ
Why?
Obsidian's editor (CodeMirror 6) normalizes all line endings to LF (\n) internally. When you open a file with CRLF (\r\n) line endings â even if you make no edits â and save it, Obsidian silently converts all line endings to LF.
If your project uses CRLF (common on Windows, or enforced by .editorconfig / .gitattributes), this causes:
- Unexpected Git diffs â every line appears changed
- CI failures â linting rules like
linebreak-stylefail - Team friction â mixed line endings across the codebase
This plugin fixes line endings automatically after every save (and optionally on file open), so your files always have the line endings you expect.
Features
- đ§ Auto-fix on save â line endings are corrected immediately when you save a file
- đ Auto-fix on open â (enabled by default) corrects line endings when you open a file
- đ Per-file / per-folder rules â different line ending strategies for different parts of your vault
- đ Status bar indicator â shows the current file's line ending (
LF/CRLF) at a glance - ⥠Manual commands â convert any file to LF or CRLF on demand
- đ Chinese / English i18n â UI language follows Obsidian's display language
Configuration
Open Settings â Line Ending Controller to configure rules:
| Setting | Description |
|---|---|
| Pattern | Path prefix to match (e.g. projects/ or docs/spec.md). Empty matches all files as fallback. |
| Strategy | LF (Unix) â force LF line endingsCRLF (Windows) â force CRLF line endings |
Rules use longest prefix matching â more specific rules take priority. The rule with an empty pattern acts as the default for all unmatched files.
Example
| Pattern | Strategy | Effect |
|---|---|---|
| (empty) | CRLF | All files â CRLF |
linux-scripts/ | LF | Files under linux-scripts/ â LF |
docs/README.md | LF | Only docs/README.md â LF |
Result: docs/README.md and everything under linux-scripts/ uses LF; everything else uses CRLF.
Commands
This plugin adds two commands to the Command Palette (Ctrl+P):
| Command | Description |
|---|---|
| Convert current file to LF | Immediately converts the active file to LF |
| Convert current file to CRLF | Immediately converts the active file to CRLF |
Installation
From Obsidian Community Plugins
- Open Obsidian â Settings â Community Plugins
- Disable Safe mode
- Click Browse and search for "Line Ending Controller"
- Install and enable
Manual Installation
- Download
main.js,manifest.json,styles.cssfrom the latest release - Copy them to
<Vault>/.obsidian/plugins/line-ending-controller/ - Restart Obsidian and enable the plugin in Settings
From Source
git clone https://github.com/anseyuyin/line-ending-controller.git
cd line-ending-controller
npm install
npm run build
# Then copy main.js, manifest.json, styles.css to your vault
FAQ
Q: Does this plugin modify files without me saving? A: By default, yes â the "Fix on open" option corrects line endings when you open a file. You can disable this in settings.
Q: Will this cause merge conflicts in Git? A: No. The plugin ensures consistent line endings, which prevents merge conflicts caused by mixed line endings.
Q: Does it work on mobile? A: No â desktop only.
Q: Can I exclude certain files? A: Not directly, but you can use path prefix rules to control which files get which strategy. Files not matched by any rule use the empty-pattern fallback.
Development
git clone https://github.com/anseyuyin/line-ending-controller.git
cd line-ending-controller
npm install
npm run dev # watch mode â auto-rebuilds on changes
npm run build # production build
Project Structure
âââ src/main.ts # Plugin source
âââ main.js # Bundled output
âââ manifest.json # Plugin metadata
âââ styles.css # Plugin styles
âââ esbuild.config.mjs # Build configuration
âââ version-bump.mjs # Version management
âââ versions.json # Version compatibility map
Releasing
npm version patch # or minor / major
git push --tags
GitHub Actions will automatically build and create a draft release.
License
MIT
For plugin developers
Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.