Wishlist: auto_format modified lines only?
dnwe opened this issue · 2 comments
Is it possible to provide g:clang_format#auto_format
but which only reformats the lines that have been modified since the buffer was last saved?
No, it's not possible.
Each chunk of modified lines requires executeing clang-format
to format. It'll be a heavy work for Vim and it takes a lot, I think.
Though there is no feature to format modified lines automatically, I think it is better way to format per each modifying with remembering the line when you enter insert mode and invoking clang-format
automatically when you leave insert mode. You can hook these points using InsertEnter
and InsertLeave
events.
Hi, I added automatic formatting on InsertLeave
as a trial at c83f840.
If g:clang_format#auto_format_on_insert_leave
is 1
, inserted lines are automatically on leaving insert mode. Please be careful because this feature has some side effects.
- Sometimes auto-formatting moves screen unintentionally.
- Cursor position history is polluted (Issue #8).