Yeah I split it up all the time. It can be a pain depending how the code is structured as git can pick some funny ways to diff it (e.g. it doesn't do well when extracting code into a new function you put just under the original). I'll have to give fugitive a go and see how it compares next time I get an ugly split patch.
When I come into this scenario where Git isn't splitting it how I want to, I normally use the edit function and just edit the hunk. This opens the hunk in $EDITOR (vim!) and I get by with it. I don't love it since editing the + / - manually can be pretty error-prone. What's your workflow with using Fugitive to selectively stage hunks?
With fugitive, you get a split with the old file and new file. You can pull in your changes one patch at a time or highlight one line and push it over. It’s really handy for print statements that you want to delete from the commit.
For git blame it shows line by line next to the file. It’s great for using with :Glog which lets you flip through revisions.
If you always remember to remove your debug statements, you’re a better person than me ;) That’s just the most common mistake that I catch in my code review.
And, :Glog with :Gblame is the killer feature. :Glog lets you page through the versions of the file and then :Gblame let’s you see who did what in each version. So, it would be like git blaming every version of a file.
Sometimes I’ll even commit around a debug statement if I want to lock in something I know is correct but I want to keep the debug statements around while I work on the next thing.
Having git blame easily available per line via :Gblame, and being able to view the commit, or go to the previous version of the file at that commit is nice.
Being able to use the :Gstatus to commit or uncommit changes, or patch a given file is nice.
Being able to :Gread to basically :!git checkout % is nice.
A bunch of neat stuff like that. How do you normally handle git?
Same, the only real use I’ve found for it is blame.. Other than that, it just seems like the git command line has everything I need. I could be missing out I guess.
10
u/JonDum Oct 26 '19
Been using vim for 15+ years and I still don't use it or see the value in it. What am I missing?