Sublime Forum

Whitespace gone after pasting contents

#1

Hi there

When I have both preferences set to true, Sublime is having issues:

    "save_on_focus_lost": true,
    "trim_trailing_white_space_on_save": true

For example I type var then hit the space bar and want to paste code with CTRL-v then it is losing focus, does a save and trims the white space. And my code is messed, the space after var is gone.

PS: I also posted this issue on GitHub at github.com/SublimeText/Issues/issues/170

0 Likes

#2

What is the behaviour you’re expecting? Sounds like everything is working fine to me…

0 Likes

#3

I think my above post is not clear. Let me clarify:

  1. I have this content in the clipboard: “var a = b;”
  2. I am currently editing a file with these contents. The dots are whitespaces!

function test() { .... }

  1. Now, I want to paste the contents inbetween and expect a result like this:

function test() { ....var.a.=.b; }

  1. But I have this:

function test() { var.a.=.b; }

You can see, intendation is gone. Lost after pasting the contents.

This bug makes it so painful to work with Sublime. Makes me almost want to change to a different IDE.

Any clues why this is happening?

0 Likes

#4

Are you entering the spaces, then pasting right away? Or are you going to another window? If you are going to another window, I believe everything is working correctly. You are losing focus, thus triggering a save. The save then trims white spaces. Thus, when you return, there are no white spaces. To get around this, you could bind the save key binding to a custom save command, that will perform the trim, then save. This would allow you to disable trim_trailing_white_spaces_on_save. Of course, then to trim the white spaces, you would have to use the key bindings.

0 Likes