-
Notifications
You must be signed in to change notification settings - Fork 82
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
automatic whitespace removal not working #127
Comments
|
Yes I want this behaviour :) |
I can confirm the issue. It works with :StripWhitespace but not automatically on save. |
I’m sorry but I don’t have neovim so I can’t test this issue that easily. Basically we trigger stripping on
Events 1 and 2 can be easily tested by adding a vim-better-whitespace/plugin/better-whitespace.vim Lines 361 to 363 in 8cf4b21
vim-better-whitespace/plugin/better-whitespace.vim Lines 257 to 258 in 8cf4b21
To test the diff output, you could run from a modified buffer: :echo system(g:diff_binary.' -a --unchanged-group-format="" --old-group-format="" --new-group-format="%dF,%dL " --changed-group-format="%dF,%dL " '.shellescape(expand('%')).' -', join(getline(1, line('$')), "\n") . "\n") The output should be the list of modified lines as |
I had this problem as well, I'm in Neovim too, so maybe it is that. But I fixed it with: g.better_whitespace_enabled = 1
g.strip_only_modified_lines = 1
vim.cmd("autocmd BufWritePre * :StripWhitespace") or plain Vimscript I guess it would be:
|
I have the same issue on Vim 9.0. Relevant .vimrc config is:
|
Same here. NVIM v0.9.1
In my environment it seems to be related to the file type. Editing simple text files doesn't seem to trigger the problem, ie spaces are removed on save, but JSON and YAML files do exhibit the problem, ie spaces are not removed on save. Thanks @tombh, your work-around fixes it for the time being. |
Tried reproducing on nvim, but works as intended for me. Here’s the setup:
@tombh is basically running Does force-enabling the behaviour work, i.e. doing |
I'm also experiencing this. Some things I found (using a test file
|
fixes ntpeters#127 (and maybe others?)
fixes ntpeters#127 (and maybe others?)
@Cimbali I think I found the underlying issue. While the I assume similar problems can be caused by other plugins using auxiliary buffers which cause the autocmds to be deleted and do not trigger a re-setup of the autocmds before the actual write. E.g., it looks to me that #147 might be caused by such a problem (but I did not check, since I don't use NERDTree). Not sure what's the correct/best way to fix this, but locally I'm using buffer-specific autocmds to trigger whitespace highlights/deletions, which seems to work fine so far. |
Thanks @pitkling these changes seem to make a lot of sense anyways, as all decisions of highlighting are made per buffer, scoping autocommands to buffers is logical. Feel free to open a PR and I'll try to inspect it more closely. |
Forgot to mention here: I opened a corresponding PR (#168). |
Hi all!
I use vim-better-whitespace now for some time and have the following configuration:
let g:better_whitespace_enabled=1
let g:strip_whitespace_on_save=1
let g:strip_whitespace_confirm=0
let g:strip_only_modified_lines=1
I just want that the plugin removes my trailing whitespace when I save a file.
Apparently it stopped working now and I have no clue why.
Is use vim-plug and neovim (NVIM v0.4.3) .
Is there somebdy with the same problem?
The text was updated successfully, but these errors were encountered: