Misspell Fixer is a command-line utility designed to automatically detect and correct common misspellings and typos in source code. The tool addresses frequent spelling errors that commonly appear in program code, including those found in comments, documentation, examples, and code samples. This utility enables rapid correction of numerous spelling errors across large codebases.
Please note that this utility does not modify file names. If a misspelled word appears in both a file's content and its name, only the content will be corrected; the file must be manually renamed.
Exercise extreme caution when applying corrections to public APIs, as spelling changes may introduce breaking changes for dependent systems.
Manual code review is always required after running this tool to ensure that corrections have not introduced unintended changes or broken functionality.
misspell-fixer [OPTION] target[s]
target[s] can be any combination of files or directories.
-rExecute in real mode: Overwrites original files with corrected versions. Without this option, original files remain unmodified.-nDisable backup creation. By default, modified files are backed up with a.$$.BAKsuffix.-P nEnable parallel processing usingnworker processes. Example:-P 4processes files using 4 threads. Note:-soption is incompatible with parallel processing.-fEnable fast mode (equivalent to-P4).-hDisplay help information.
Performance considerations: The -s, -v options, or absence of -n or -r utilize slower internal processing loops. For optimal performance, use -frn without -s and -v.
-sDisplay diff output showing proposed changes.-vEnable verbose mode: Display each file as it is processed (excludes prefiltering step).-oEnable progress mode: Display processing progress (prints a dot for each scanned file, comma for each fix iteration).-dEnable debug mode: Display detailed information about core logic steps.
By default, approximately 100 carefully selected rules are enabled. Additional rule sets can be activated using the following options:
-uEnable less conservative rules (requires more careful manual review). Adds approximately 10 rules.-gEnable British English to US English conversion rules. These address regional spelling differences rather than actual errors. Adds approximately 10 rules.-REnable rare misspelling rules. Adds several hundred additional rules.-VEnable very rare misspelling rules, primarily sourced from Wikipedia articles. Adds over 4,000 rules.-DEnable rules derived from lintian.debian.org (git:ebac9a7). Adds approximately 2,300 rules.
Processing performance decreases with additional rule sets enabled, though modern grep implementations significantly mitigate this impact.
-GRespect.gitignorefiles (requiresgitcommand in PATH). This feature is experimental.-NEnable filename pattern filtering. Example:-N '*.cpp' -N '*.h'processes only C++ source files.-iInclude version control system directories (process.git,.svn,.hg,CVSdirectories).-bProcess binary and generated files (do not ignore*.gif,*.jpg,*.jpeg,*.png,*.zip,*.svg,*.tiff,*.gz,*.bz2,*.xz,*.rar,*.po,*.pdf,*.woff,yarn.lock,package-lock.json,composer.lock,*.mo,*.mov,*.mp4,*.jar).-mDisable file size filtering. Default behavior ignores files larger than 1MB (typically CSV files, minified JavaScript, etc.).
Misspell Fixer automatically excludes issues matching patterns listed in .misspell-fixer.ignore or .github/.misspell-fixer.ignore.
The ignore file format follows the prefiltering temporary result format:
^filename:line number:matched word
-WAppend discovered issues to the ignore file instead of applying fixes based on other settings.-w filenameSpecify a custom ignore file path (overrides default ignore file locations).
The ignore file functions as a grep exclusion list, applied after the prefiltering step. This enables exclusion of specific prefixes or entire files. To exclude complete files, use only the filename:
^filename
To exclude an entire directory:
^directory
Path matching is based on the current invocation context.
Accessing the same target via different paths from the same working directory may not apply
whitelist entries consistently. For example, in directory x, whitelist entries created with
target . will not apply to target ../x, despite referencing identical content.
Manual editing of the whitelist file can work around this limitation.
The script returns exit code 0 when no typos or errors are found or fixed.
0No typos detected1-5Typos found and processed. The return value indicates the number of processing iterations executed10Help information successfully displayed11Whitelist file successfully saved100+Parameter errors (invalid, missing, or conflicting options)
Check for typos without making changes (minimal output): Return value can be used to detect whether it found any typos or not.
$ misspell-fixer target
Apply fixes with verbose file reporting:
$ misspell-fixer -rv target
Display proposed changes without modifying files:
$ misspell-fixer -sv target
Display changes with progress indicators and apply fixes:
$ misspell-fixer -rsv target
Maximum performance mode (fast processing, no backups):
$ misspell-fixer -frn target
Maximum performance with all rule sets enabled:
$ misspell-fixer -frunRVD target
This tool incorporates misspelling databases from the following sources:
- https://en.wikipedia.org/wiki/Commonly_misspelled_words
- https://github.com/neleai/stylepp
- https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines
- https://anonscm.debian.org/git/lintian/lintian.git/tree/data/spelling/corrections
- http://www.how-do-you-spell.com/
- http://www.wrongspelled.com/
For environments where dependency management presents challenges (macOS, Windows, legacy Linux distributions), Misspell Fixer is available as a Docker container image.
Pull the latest container image:
$ docker pull vlajos/misspell-fixer
Process the contents of targetdir:
$ docker run -ti --rm -v targetdir:/work vlajos/misspell-fixer -frunRVD .
Standard Docker execution:
$ docker run -ti --rm -v targetdir:/work vlajos/misspell-fixer [arguments]
The targetdir becomes the working directory within the container and can be referenced as . in the arguments.
Using the included dockered-fixer wrapper script:
$ dockered-fixer [arguments]
Creating a shell function for convenience (bash/zsh):
$ function misspell-fixer { docker run -ti --rm -v $(pwd):/work vlajos/misspell-fixer "$@"; }
Using the shell function:
$ misspell-fixer [arguments]
Both the wrapper script and shell function can only access directories below the current working directory, as only the current directory is mounted as a volume in the container.
To build the container locally:
$ docker build . -t misspell-fixer
A GitHub Action is available for integrating Misspell Fixer into CI/CD workflows. The action supports automatic pull request creation with proposed fixes.
Misspell Fixer is implemented as a bash script that coordinates between established Unix utilities (mainly grep and sed.
The core functionality leverages grep's -F flag for efficient parallel pattern matching using the Aho–Corasick algorithm, combined with sed's targeted line modifications.
Proper -w (whole word) support requires grep version 2.28 or later.
- bash
- find
- sed
- grep (version 2.28+ recommended)
- diff
- sort
- tee
- cut
- rm, cp, mv
- xargs
- git (required for
.gitignorefile support) - ugrep (provides significant performance improvements when available)
- Veres Lajos
- ka7
https://github.com/vlajos/misspell-fixer
This project is open source and freely available for use.