Remove trailing whitespace on save in IntelliJ IDEA 12

孤者浪人 提交于 2019-12-03 01:58:13
Vic

Don't know about 12, but there's the following setting in 13:

Settings → Editor → Strip trailing spaces on Save

As of IntelliJ 2017.2 it's under

Settings → Editor → General → Strip trailing spaces on Save

Add an external tool. As the Program pass /usr/bin/sed (may be different on your box, run which sed to locate) and insert the -i 's/[[:space:]]\+$//' $FilePath$ in the Parameters. Overall the command that you want IntelliJ to run is,

/usr/bin/sed -i 's/[[:space:]]\+$//' <your current file>

This sed will remove the trailing whitespace, and overall the effect will be very similar to git. Next you can add a keyboard shortcut for your new external tool entry, but I am not sure whether it is possible to run anything on save.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!