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

Remove trailing white spaces on the changed lines #413

Open
fenghse opened this issue Mar 26, 2024 · 1 comment
Open

Remove trailing white spaces on the changed lines #413

fenghse opened this issue Mar 26, 2024 · 1 comment

Comments

@fenghse
Copy link

fenghse commented Mar 26, 2024

I am switching from vim-gitgutter to this new plugin, it is fast! Thanks.

But I am relying on following function to remove the trailing white spaces on the new added lines.

function! GlobalChangedLinesGutter(ex_cmd)
  for hunk in GitGutterGetHunks()
    for lnum in range(hunk[2], hunk[2]+hunk[3]-1)
      let cursor = getcurpos()
      silent! execute lnum.a:ex_cmd
      call setpos('.', cursor)
    endfor
  endfor
endfunction

command! -nargs=1 Glines call GlobalChangedLinesGutter(<q-args>)
autocmd BufWritePre * :Glines s/\s\+$//e

Is there equivalent API available from vim-signify to support this? Thanks.

@jamessan
Copy link
Collaborator

jamessan commented Apr 5, 2024

b:sy.hunks has all the detected hunks. That may not be up to date at BufWritePre time, depending on whether Sy has had a chance to refresh since your last modification.

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

No branches or pull requests

2 participants