Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%s causes the entire file to have whitespace stripped #13

Open
dylan-chong opened this issue Jul 6, 2018 · 4 comments
Open

%s causes the entire file to have whitespace stripped #13

dylan-chong opened this issue Jul 6, 2018 · 4 comments

Comments

@dylan-chong
Copy link

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)

@thirtythreeforty
Copy link
Owner

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.

@henrebotha
Copy link

henrebotha commented Mar 21, 2019

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.

@dylan-chong
Copy link
Author

dylan-chong commented Mar 21, 2019 via email

@henrebotha
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants