On Sat, May 27, 2023, 13:02 Enan Ajmain <3nan.ajm...@gmail.com> wrote:

>
> Igor:  I second Matvey's caution.  If you are working on a project that
> has an autoformat tool which all contributors are supposed to be using,
> e.g., uncrustify, then autoformatting could possibly be useful.  But if
> you're working on a project that imposes no such formatting guideline,
> then auto formatting code someone else wrote, which doesn't concern the
> logic you're coding in a particular commit, is at best unhelpful for the
> other contributors.  And I mention other contributors because judging by
> your comments such as "Looks like those people never coded in their
> life," it's reasonable to expect you code in projects with multiple
> people, not just yourself.
>
> And as for a suggestion to your original question: see ':h formatprg',
> ':h formatoptions', ':h formatexpr', etc.
>
>
> --
> Enan
>

The other problem with reformatting an entire file is that you lose
history. Git, for example, has a feature called blame (or credit, depending
on your frame of mind) that will tell you the last person who modified each
line and the corresponding git commit, which is useful if you have
questions about a particular block of code and want to know whom to ask. If
you reformat the entire file, though, then it will appear as if you wrote
the entire file. Regrettably, this isn't just hypothetical: I've
occasionally asked a developer about some code only to be told that they
only reformatted it to make it pretty and can't actually explain what it's
doing.

A better solution would be for you to figure out exactly which lines you've
changed and only operate on those. I did recently write something in Vim9
to do this and use it to strip trailing spaces and things like that, but
only from lines I've added or modified. (Back when I wrote it, I asked if
there was any interest and no one expressed any, so it's not really in a
state where it's ready to be consumed by other people as a proper plugin.)

Salman

>

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/CANuxnEcwo%2BUZ-SwATzBmm52__VX9Q-%2Bp-Tk50G61qDzt5oRTGw%40mail.gmail.com.

Reply via email to