Trailing space

Answered

I wanted to write a feature request, but it this one seams too personal. So I want to ask about the way IDEA-based ides (currently testing PhpStorm) save files. Is it automatic? I noticed that I don't have to press ctrl-s to save files.

That leads to a little problem. I'm used to having cursor not able to go past the end of the line. But I'm also used to editors trimming white space on save. With autosave this is not possible because at the moment the save happens the cursor will not be indented anymore. So consider this code:

__$a=1;
__callFunc(); 

(underscore shows white space)

So I want to put empty line between these two lines. I go to the end of first line and press enter:

__$a=1;
__
__callFunc(); 

Now I end up with white space. Allowing the cursor to go past the end of the line fixes this problem, but now I have to press End every time I use  mouse to go to the end of the line. That's not too often - I use mostly keyboard, but it's what I'm used to.

The problem would be resolved with "trim trailing space on save" option.

Of course I could get used to having the cursor after the end of the line, but I'm considering IDEA IDEs because it's highly customizable and I don't have to get used to anything. I just configure it as the editors I'm used to and it just works.

0
15 comments
Official comment

Hello,

Please check available options under Settings > Editor > General > Strip trailing spaces on Save & corresponding dropdown menu

 

Thanks!

Thanks for the response.

Yes, I did, but what I need is all spaces (including current line) to be trimmed with "allow placement of caret after end of line" unchecked(that's usually done on save and the caret goes back to the end of line when spaces are trimmed):



0

Thanks, after some testing I've got your point.

This feature was actually requested as a part of a bug report. Here's an original report explaining overall behaviour and here's a request to allow stripping whitespaces on manual save. Please vote for it to move it in a queue and receive updates on progress.

 

Currently it's impossible to set this as you've described, unfortunately.

 

0

So I'm not the only one requesting "trim white space on manual save". It's good I didn't post feature request to pollute the bug tracker with duplicates. I think IDEA-114099 request is exactly what I need. How do I vote?

0

Yup, thank you for an attentive approach.

In short, you would need to sign into Youtrack and click on a Vote button on a right side of a page. Here it is described in details.

0

Found it - I voted and wrote my wish as a comment. Thanks for directing me to this feature request in bug tracker!

0

You're more than welcome!

0
Avatar
Permanently deleted user

hello I configured Settings > Editor > General > Strip trailing spaces on Save to Strip All but it's not stripping anything, on save or after selecting everything and pressing Ctrl+Alt+L .. nothing works, in Fact, when I Reformat with Ctrl+Alt+L it adds extra spaces

This is AFTER reformating.

This feature used to work perfectly in the previous version of WS, now it's not working. I'm using 2016.2.2

0

Could you please paste the build number you're using (Help > About). What OS is it on?

0
Avatar
Permanently deleted user

It's actually WS. I'm running Windows 10 x64

 

0

Please try to:

1) disable all custom plugins

2) restart OS

Check if the issue is the same after this. Also try to switch to a default Code Style scheme in File | Settings | Editor | Code Style

0
Avatar
Permanently deleted user

what do you mean by "custom plugins"? 

I've just checked and I have another React JSX project in which the Stripping works fine, so the problem seems to be in one particular proyect

0
Avatar
Permanently deleted user

Hello, the problem is fixed now, alas I don't really know what it was, I simply switched the Code Style from a custom one to another custom one that worked fine and the bug is gone.

0

Yes, looks like there was something misconfigured in code style settings.

0

Please sign in to leave a comment.