NewLineAutomatically ensures every file ends with exactly one blank line when saved. No more missing newlines or multiple trailing blank lines. Features
InstallationSearch for NewLine in the VS Code Marketplace and click Install, or run:
UsageThe extension activates automatically. Every time you save a file, it checks and fixes the trailing newline. Newline checks inspect lines backward from the end instead of reading the whole document. Work depends on the trailing empty lines and the final content line; newline-only files and very long final lines can still require substantial processing. With Git protection enabled, comparison also examines only the ending, although the Git API still returns the complete index version of the file. To trigger a check manually, open the Command Palette (
Configuration
|
| Field | Values | Description |
|---|---|---|
type |
"basename" | "fullName" |
Match against the filename only, or the full absolute path |
regex |
string | A JavaScript-compatible regular expression |
// settings.json
"newline.fileRegexToIgnore": [
// ignore any file named exactly "Makefile"
{ "type": "basename", "regex": "^Makefile$" },
// ignore all files under a "vendor" directory
{ "type": "fullName", "regex": "[/\\\\]vendor[/\\\\]" },
// ignore all .min.* files
{ "type": "basename", "regex": "\\.min\\." }
]
newline.ignoreOnlyNewlinesFile
When set to true (the default), files whose entire content consists only of newline characters are left untouched. Set to false to strip those newlines as well.
newline.ignoreSourceControlledFiles
Set to true to avoid unrelated end-of-file changes in Git-tracked files:
"newline.ignoreSourceControlledFiles": true
On save, the current editor content (including unsaved edits) is compared with the Git index (staging area). If the last non-empty line and all trailing newlines are unchanged, NewLine skips the file. Editing that last line, adding content at the end, or changing trailing newlines allows normal newline cleanup. Changes earlier in the file do not trigger cleanup. LF and CRLF are treated as equivalent for this comparison.
The index is the baseline, so staged changes are already part of the comparison version. Newly staged files are also covered. Untracked files continue to use normal newline cleanup. This option requires VS Code's built-in Git extension; other source control providers are not supported. If Git is unavailable, reading the index fails, or the check takes longer than 500 ms, normal cleanup applies.
The manual NewLine: Check Newline command still forces a check regardless of this option.
Issues & Feedback
Found a bug or have a suggestion? Please open an issue.
Contributing
pnpm install # install dependencies (requires Node.js with corepack enabled)
pnpm run compile # compile TypeScript
pnpm run lint # run linter
pnpm run test # compile and run tests (no display required)
Commit messages must follow Conventional Commits — releases are automated via Semantic Release.
Releases
The Release workflow runs on pushes to master
and can also be started manually on that branch. Lint and tests must pass before
Semantic Release runs. Release jobs are serialized to prevent concurrent version
updates.
| Commit | Release |
|---|---|
fix: ... |
Patch |
feat: ... |
Minor |
feat!: ... or a BREAKING CHANGE: footer |
Major |
docs: ..., chore: ..., refactor: ... |
No release by themselves |
.releaserc.json controls release generation. Semantic Release
updates CHANGELOG.md and package.json, builds the VSIX, commits the release
files using @semantic-release/git, creates a version tag and GitHub Release with
the VSIX attached, and publishes that package to the VS Code Marketplace. It does
not publish an npm package. Do not manually bump versions or add upcoming version
entries to the changelog; use descriptive Conventional Commits instead.
Repository setup requires a VSCE_PAT Actions secret with Marketplace publishing
permission. The workflow uses the automatic GITHUB_TOKEN to publish GitHub
releases and push release commits; branch rules must permit these pushes.
Release commits use chore(release): <version> [skip ci] to avoid another build.
Run pnpm run release:dry-run with GitHub credentials to preview the next release
without generating files or publishing. Marketplace publishing is verified by the
actual release, not by the dry run.
Credits
Inspired by vsCodeBlankLine.