Working with Git inside Vim
whynothugo.nl·1w
📂Git
Preview
Report Post

My workflow since time immemorial has been to use a code editor (Vim/Neovim) to edit code, and then the git command line tool to operate on the repository. This flow included switching to the command line for git add -p or git diff.

Each time I made a small tweak on an existing change, I had to switch back to the terminal and git add -p, skip irrelevant changes, and stage the one I want.

At some point I thought to myself “you can do better”. In recent months, I added two sets of keyboard mappings which have dramatically changed how I work.

Jump to changes

[permalink]

The set of mappings is:

nnoremap <expr> ]c &diff ? ']c' : '<Cmd>Gitsigns next_hunk<CR>'
nnoremap <expr> [c &diff ? '[c' : '<Cmd>Gitsigns prev_hunk<CR>'

These two are sym…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help