lessspace.vim icon indicating copy to clipboard operation
lessspace.vim copied to clipboard

%s causes the entire file to have whitespace stripped

Open dylan-chong opened this issue 6 years ago • 4 comments

file (add some whitespace to each line when testing):

private bla() {
  sdfkljsdlkfj sdkl fjask ljakl sjdfkl jkl  
}   

open vim with that file and make sure that you have the whitespace saved.

now open vim and have lessspace enabled. run :%s/private/public/<CR> and now the whitespace is stripped from every line, not just the 1st line (which would be the ideal behaviour)

dylan-chong avatar Jul 06 '18 05:07 dylan-chong

So it looks like this does an actual edit to every normal mode line, sometimes just replacing it with itself. That is, it does not edit the lines in place.

I agree it would be ideal not to strip the un"modified" lines, departing from the Vim definition of "modified." Maybe the plugin should save the unmodified line every time the line number changes, then check if the line has been truly modified after manual changes.

Of course, that presumes that the cursor actually moves during a normal mode regex, which may not be the case. None of that behavior is documented, so I'd need to play around with it.

thirtythreeforty avatar Jul 09 '18 21:07 thirtythreeforty

I just tried to reproduce this behaviour, but couldn't. This was on Vim 8.1 (my own compiled version). The test file I used (note trailing whitespace on each line):

some spaces here     

some more here     

and again      

The test command was :%s/here/there/.

Unless someone can reproduce, I vote we close.

henrebotha avatar Mar 21 '19 14:03 henrebotha

Just a sanity check: Are you sure white space is actually getting stripped at all?

On 22/03/2019, at 3:43 AM, Henré Botha [email protected] wrote:

I just tried to reproduce this behaviour, but couldn't. This was on Vim 8.1 (my own compiled version). The test file I used:

some spaces here

some more here

and again
The test command was :%s/here/there/.

Unless someone can reproduce, I vote we close.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

dylan-chong avatar Mar 21 '19 17:03 dylan-chong

Good catch! It's not. So it's a different bug then: %s is not causing whitespace to strip on affected lines.

henrebotha avatar Mar 22 '19 09:03 henrebotha