Cleaning trailing spaces out of code without losing its indentation
Open a code review and some changes are nothing but whitespace: a line marked as changed because it lost or gained a space at the end. Editors add these quietly, and they make real changes harder to see. Many projects reject trailing spaces in their style checks for this reason. When you have a file full of them and no editor setting at hand, this tool fixes it in one paste.
Choose End only. Each line loses the spaces and tabs after its last character, and nothing else changes. The indentation at the start of each line stays, so a Python function is still a Python function and a nested YAML list keeps its levels. The note under the result says how many lines were trimmed, for example "Trimmed 37 of 210 lines", which is the same number a diff will show as changed when you save it.
Both ends is for data. A column of names copied from a spreadsheet often has a space after some of the values, and a list typed by hand sometimes has a space before a few. Those spaces make "Smith" and "Smith " different values to a lookup or a deduplicate. Trimming both ends makes every line start and end with a real character. Start only does the opposite job to End only: it flattens indented text, such as a quoted email reply, back to the left margin.
Two things are kept on purpose. First, line breaks: each line keeps its own break, so a Windows file keeps its Windows line breaks and git will not see every line as changed. A final line break at the end of the file is kept as well. Second, no-break spaces: they are left alone, because someone usually typed them on purpose to keep two words together.
The tool has limits. It works on spaces and tabs only, so it will not remove a zero-width space or a no-break space at the end of a line; the Whitespace Visualizer shows those. It does not touch the spaces between words, and it does not remove empty lines. It takes up to 1 MB of text at a time, which is far more than most source files.