Skip to content

hk util trailing-whitespace ​

  • Usage: hk util trailing-whitespace [-d --diff] [-f --fix] <FILES>…
  • Effect: modifies state

Check for and optionally fix trailing whitespace

Only spaces and tabs before a line's terminator count as trailing whitespace. Each line keeps its own terminator, so a CRLF file stays CRLF.

Arguments ​

  • <FILES>… — Files to check/fix

Flags ​

  • -d --diff — Output a diff of the change. Cannot use with fix.
  • -f --fix — Fix trailing whitespace by removing the spaces and tabs
  • -h --help — Print help

Examples ​

Check first, or remove trailing whitespace in place.

sh
hk util trailing-whitespace README.md
hk util trailing-whitespace --fix README.md

Learn more ​

Built-in linters and utilities · Troubleshooting · All commands

MIT LicenseCopyright © 2026jdx.dev