Clean up: Difference between revisions
From Nasqueron Agora
+trailing spaces |
mNo edit summary |
||
| Line 22: | Line 22: | ||
Git has a filter to be able to normalize with expand. See [https://eev.ee/blog/2016/06/04/converting-a-git-repo-from-tabs-to-spaces/ here]. | Git has a filter to be able to normalize with expand. See [https://eev.ee/blog/2016/06/04/converting-a-git-repo-from-tabs-to-spaces/ here]. | ||
== Trailing spaces == | === Trailing spaces === | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
$ git ls-files | xargs -n 1 gsed -i 's/[[:space:]]*$//' | $ git ls-files | xargs -n 1 gsed -i 's/[[:space:]]*$//' | ||
Latest revision as of 14:00, 9 March 2026
Style
EOL at EOF
There is a need for a blank line at end of file.
You can add them with echo.
$ git ls-files | while read f; do tail -n1 $f | read -r _ || echo >> $f; done
UNIX lines
$ dos2unix
Encoding
$ iconv -f iso-8859-15 -t utf-8
Tab to spaces
Git has a filter to be able to normalize with expand. See here.
Trailing spaces
$ git ls-files | xargs -n 1 gsed -i 's/[[:space:]]*$//'
UTF-8 BOM
Some old editors started a file by the sequence of bytes [0xEF, 0xBB, 0xBF] to allow the UTF-8 file encoding to be detected. This practice is discouraged nowadays and those should removed.
$ sed -e '1s/^\xef\xbb\xbf//' < bomfile > newfile
