r/vim • • Oct 26 '19

meta What "Git for Windows" developers think of our favorite text editor.

Post image
553 Upvotes

109 comments sorted by

View all comments

Show parent comments

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?

0

u/[deleted] Oct 26 '19

[deleted]

1

u/spinlock Oct 26 '19

I use it to patch commit everything. I like reviewing the code one last time before the commit.

It’s also really easy to see prior versions of a file and git blame to see who/when code was written.

0

u/[deleted] Oct 26 '19

[deleted]

4

u/vimfan Oct 26 '19

By patch commit, they probably mean git add -p

1

u/spinlock Oct 27 '19

Yup. But, have you ever tried to split a patch? With fugitive, you can highlight exactly what you want to commit and leave out what you don’t want.

4

u/vimfan Oct 27 '19

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.

1

u/100degreeplastic Oct 28 '19

Could you expand?

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?

1

u/spinlock Oct 28 '19

You highlight what you want and :diffpush it over.

It’s super easy to use.

1

u/spinlock Oct 26 '19

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.

0

u/[deleted] Oct 27 '19

[deleted]

1

u/spinlock Oct 27 '19

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.

0

u/[deleted] Oct 27 '19

[deleted]

1

u/spinlock Oct 27 '19

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.

4

u/TankorSmash Oct 26 '19

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?

1

u/[deleted] Oct 27 '19

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.