Set PhpStorm to remove trailing spaces on lines

Go under File>>Settings

On the search bar type: trailing

Then under Editor>> Strip trailing spaces on Save: >> Select All from selection options

Hit Apply and then go into every file saving and correcting your coding standard:

~$ phpcs src/Cordova/FilmothequeBundle/

result:

~/sites-2/memorizescripture$ phpcs src/Cordova/FilmothequeBundle/

FILE: ...ites-2/memorizescripture/src/Cordova/FilmothequeBundle/Entity/Movie.php
--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 7 WARNING(S) AFFECTING 7 LINE(S)
--------------------------------------------------------------------------------
17 | WARNING | Please trim any trailing whitespace
22 | WARNING | Please trim any trailing whitespace
27 | WARNING | Please trim any trailing whitespace
33 | WARNING | Please trim any trailing whitespace
38 | WARNING | Please trim any trailing whitespace
44 | WARNING | Please trim any trailing whitespace
120 | WARNING | Consider breaking lines longer than 80 characters; contains
| | 100 characters
--------------------------------------------------------------------------------

Time: 0 seconds, Memory: 3.00Mb

Do your saving operation and then get:

~/sites-2/memorizescripture$ phpcs src/Cordova/FilmothequeBundle/
Time: 1 second, Memory: 3.00Mb

Done.

PS> https://github.com/aYaline/Symfony2-coding-standard

2 thoughts on “Set PhpStorm to remove trailing spaces on lines

  1. A hint for codesniffer and phpstorm users:

    Go under File>>Settings

    On the search bar type: External tools.

    Add a command for phpcs.with –report=emacs in command line and add an output filter like $FILE_PATH$:$LINE$:$COLUMN$ as an external command

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">