gitsigns.nvim
gitsigns.nvim copied to clipboard
Partial hunk staging as operator
It would be cool take advantage of the partial hunk staging feature just implemented making a operator to work with motions like:
<leader>hs3j --> stage next 3 lines
<leader>hsip --> stage paragraph
<leader>hsiw --> stage word
and so on..
Wonderful! I was just about to ask if this was possible to do!
It will be a very unique feature, I've never seen it in other Editors. @molleweide
Haha yeah I think it could be quite interesting feature
Very nice when hunks too big
All in. Was just searching the thread in advance of posting the following issue:
In gitgutter
I could work with partial hunks (from the documentation):
To stage part of any hunk:
preview the hunk, e.g. <Leader>hp;
move to the preview window, e.g. :wincmd P;
delete the lines you do not want to stage;
stage the remaining lines: either write (:w) the window or stage via <Leader>hs or :GitGutterStageHunk.
Really, really would be wonderful if gitsigns would allow me to do the same. /tms
All in. Was just searching the thread in advance of posting the following issue: In
gitgutter
I could work with partial hunks (from the documentation):To stage part of any hunk: preview the hunk, e.g. <Leader>hp; move to the preview window, e.g. :wincmd P; delete the lines you do not want to stage; stage the remaining lines: either write (:w) the window or stage via <Leader>hs or :GitGutterStageHunk.
Really, really would be wonderful if gitsigns would allow me to do the same. /tms
Agree, wanted to ask about it as well. But this should probably be moved to a seprarate issue, no?
+1
That's actually the only thing that's missing from vmi-gitgutter for this plugin to be 10/10
How does vim-gitgutter implement this, last time I checked it doesn't have true partial hunk staging like Gitsigns does, so an operator mapping doesn't make sense.
btw, not sure if anyone knows this, but if you edit a buffer created by :Gitsigns diffthis
you can save/write it to stage changes. This is opposed to vim-gitgutter that allows you to edit the hunk preview window.
btw, not sure if anyone knows this, but if you edit a buffer created by
:Gitsigns diffthis
you can save/write it to stage changes. This is opposed to vim-gitgutter that allows you to edit the hunk preview window.
This is exactly what I, and probably most other users, were looking for. I thought the quick preview window edit very handy, but already having the option to edit hunk before staging is already a game changer for me! Also, I might've missed it, but I think it would be great to have this feature documented in README
Fwiw fugitive allows you to do that too.
Visual select the changed lines that you want to stage and run Gitsigns stage_hunk
(equivalently :'<,'>Gitsings stage_hunk
).
I have the following mapping on my config
map({ 'n', 'v' }, '<leader>ghs', ':Gitsigns stage_hunk<CR>', 'Stage hunk')
This allow my to select lines (V
) then stage selected lines, i.e: V3j<Space>ghs
translates to Select the current line, move 3 lines below (4 lines selected) and stage them.