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

Sometimes you can't remove spaces when saving a file #147

Open
onlycalm opened this issue May 22, 2021 · 5 comments
Open

Sometimes you can't remove spaces when saving a file #147

onlycalm opened this issue May 22, 2021 · 5 comments
Labels
more info needed Can not solve this issue without more information

Comments

@onlycalm
Copy link

Open file via VIM. Because neardtree can move the cursor to the window where the open file is located, the space cannot be deleted when saving the file. If you move the cursor to another window and then move back to the original window, the function will return to normal.

The configuration is as follows:

"autocmd StdinReadPre * let s:std_in=1
"autocmd VimEnter * NERDTree | if argc() > 0 || exists("s:std_in") | wincmd p | endif

let g:better_whitespace_enabled=1
let g:better_whitespace_ctermcolor='gray'
let g:strip_whitespace_on_save=1
let g:strip_whitespace_confirm=0
let g:better_whitespace_operator=''
let g:better_whitespace_blacklist=[]
let g:current_line_whitespace_disabled_hard=0
let g:current_line_whitespace_disabled_soft=0

@Cimbali
Copy link
Collaborator

Cimbali commented May 22, 2021

This works for me. Do you have by any chances let g:strip_only_modified_lines = 1 ?

I’m replicating this behaviour by

  1. opening a new window
  2. doing wincmd p

So for example: vim --cmd 'au VimEnter * | vert :new | wincmd p' some_file_here

What I’m seeing is that :w and :StripWhitespace work fine with your specified config.
On the other hand :StripWhitespaceOnChangedLines does nothing (as no edits have been made yet).

@Cimbali Cimbali added the more info needed Can not solve this issue without more information label May 26, 2021
@onlycalm
Copy link
Author

onlycalm commented Jun 5, 2021

Thank you for your reply. I've uploaded two GIF files, which can explain the problems I'm facing. Can you check them?
1
2

@onlycalm
Copy link
Author

onlycalm commented Jun 5, 2021

If I move the cursor to another window and then move it back, the :w instruction can remove the space.

@onlycalm
Copy link
Author

onlycalm commented Jun 9, 2021

If you need more information, please let me know. I'm afraid I didn't describe the problem clearly. Thanks

@Cimbali
Copy link
Collaborator

Cimbali commented Jun 9, 2021

Hi @onlycalm, your screen captures seem to describe the problem well. I’m supposing some event gets missed or something but I didn’t have time to look into it yet (also I don’t have NERDTree installed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more info needed Can not solve this issue without more information
Projects
None yet
Development

No branches or pull requests

2 participants