Automatically replaces the space after a lonely single-letter word or a
configurable short word with a LaTeX hard space (~) as you type, so they never
get stranded at the end of a rendered line.
What it does
As you type in a .tex file, typing a space right after one of the
configured words (when it isn't part of a longer word or a LaTeX command
such as \w...) replaces that space with ~.
Command "LaTeX Auto Nonbreaking Space: Fix Whole Document" runs the
same fix across an entire open file at once — useful for text you already
wrote before installing this extension. Saves the document automatically
once the fix is applied.
Optional setting latexNonbreakingSpace.fixOnSave runs the whole-document
fix automatically every time you save.
Typing a second space right after an auto-inserted ~ removes it and
leaves a plain space instead — an escape hatch for when you didn't want
the hard space. Controlled by latexNonbreakingSpace.undoOnDoubleSpace
(as-you-type only; doesn't affect the fix command or fix-on-save).
Settings
Setting
Default
Description
latexNonbreakingSpace.enabled
true
Enable/disable the as-you-type replacement.
latexNonbreakingSpace.singleLetterWords
"aiouwz"
Single letters treated as lonely words (case-insensitive).
latexNonbreakingSpace.additionalWords
["do", "ze", "we", "od", "ku"]
Additional short words matched case-insensitively.
latexNonbreakingSpace.maxWordLength
0
Also match any purely alphabetic word up to this many characters (e.g. 3 matches any 1-3 letter word), on top of singleLetterWords/additionalWords. 0 disables this.
latexNonbreakingSpace.languageIds
["latex", "tex"]
Language IDs the extension is active for.
latexNonbreakingSpace.fixOnSave
false
Also fix the whole document on every save.
latexNonbreakingSpace.undoOnDoubleSpace
true
Typing a second space right after an auto-inserted ~ removes it and leaves a plain space instead.
Add your own project's settings.json to customize, e.g.: