Skip to content

Instantly share code, notes, and snippets.

@jarun

jarun/vim_git.md

Last active May 15, 2021
Embed
What would you like to do?
Useful vim and git tips

vim

daw - delete a word (under cursor)
caw - delete a word (under cursor) and put in insert mode

Remove first 5 characters in each line:

:%s/^.\{0,5\}//

Remove last two characters from each line:

%s/..$//

Swap left and right panes with ^WX.

Reader mode:

vim -R
view

vimdff merge all changes from buffer 1 to buffer 2:

:%diffget 1
:%diffput 2

git

Undo last change:

git reset --soft HEAD^
git reset --hard HEAD^

Delete a tag:

git push --delete origin tagname
git tag --delete tagname

Rebase n commits:

git rebase -i -S HEAD~n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment