Navigating Git Hunks1:12
So let's just jump up here and we'll add in something else up here, and you'll see we've already got our git diff there. I can now use [h] to jump to the next hunk and go back to the previous hunk. This is super handy if you're working in a file and you're making some changes and you want to be able to quickly jump between them. Generally, this is faster than any other way of navigating between different sections of the file that you've been working on. Let's go ahead and delete those. Next up we have the stage hunk, and I've bound this to gs, so if I say gs, it will stage
Staging and Previewing Hunks1:36
Let's go ahead and delete those. Next up we have the stage hunk, and I've bound this to gs, so if I say gs, it will stage that hunk. And if we open up a new terminal down here and we do git status, we can see that we've staged this file here, and we can do git diff --staged, and see that that has been staged. If we jump back over here though, I've set up g capital S to undo the last stage. So that can be handy if you've made a mistake. And then this next one, gp, is for preview hunk. So if we run it on this hunk, that's not super interesting, it's just showing us what the
hover over a line for one second, and then we get the commit message just showing up there at the end of the line. And you can customize that, you can customize the format of it, what it shows, how long a delay it waits for, I kind of like the one second delay because it doesn't just fly up as you're moving around your code, but if you pause, it shows up. But I still prefer not to have that anyway, so I'm going to undo that change, and save that one, and I'll run packer compile, and that should have got rid of that, excellent. Now there is one thing to note here though, if I say gs to stage this line, and let's come up to this other one here, and we'll stage that one as well. Now did you notice there that the whole screen moved over, so let's undo that one again,
Fixing Sign Column Jumping3:44
come up to this other one here, and we'll stage that one as well. Now did you notice there that the whole screen moved over, so let's undo that one again, so I'll go g shift s. Notice how that signColumn completely shifts over when we stage that line, and that's because at the moment our signColumn is set to auto, and so if there's nothing to show, then it'll collapse that line. But I don't like that behavior of it kind of jumping around. So let's go into our options.lua, and we'll come down somewhere near the bottom, and we're going to set vim.opt.signColumn equals, and we're going to say yes 1. So let's source this file, and if I go and stage this now, you'll see that it keeps that.
Viewing Git Blame Sidebar5:24
So let's install this one. We'll save this, and we'll say packasync, and let's see what this one does for us. I'm actually going to go ahead and jump into the Laravel framework in another session I have open here. Let's open this up, and we'll browse to the EloquentModel class. I think that's a good one to demonstrate things. All right, so to start with, we had the GitBlame in the other plug-in, but this one has an extra GitBlame feature that I kind of like, where it will show all of the GitBlame information on the side here, so we can see line by line who's contributed to which lines of code, and we can press enter on any of these, and we can see the full diff of what was changed.
Using Fugitive Git Status6:35
You can actually run :G, and you'll get the Git status in here, and you can stage and unstage files right from this window, but personally I still haven't gotten used to this, and I still use the git command line instead. But I'd recommend checking it out in case this fits your mental model, because being able to commit everything straight from NeoVim definitely gives you an extra speed boost. So let's close that window with :q, and let's switch back to our other project. And I can of course use gs to stage that line, and then I'd normally just jump over to my terminal to make that commit. Speaking of terminals, in the next video we'll look at having a floating terminal inside NeoVim for doing these sorts of quick terminal operations.
Next: Floating Terminal7:09
Speaking of terminals, in the next video we'll look at having a floating terminal inside NeoVim for doing these sorts of quick terminal operations.
