pockestrap

Programmer's memo

vim-operator-gitrebase つくった

タイトルのoperatorとtextobj間違えてました…orz


pocke/vim-operator-gitrebase · GitHub


git rebase の使い方についてはこちらがわかりやすいです。

初心者でも分かる!git rebaseの使い方を解説します | 株式会社LIG


$ git rebase -i @~~~~~~

とかするじゃないですか。

pick df783a0 add github ribbon
pick 0049c2b About
pick d079b6b remove bootstrap.zip
pick 4907477 add Tweet button
pick e97f412 remove TODO comment
pick cf142ab fadein result

# Rebase 7de5ac4..cf142ab onto 7de5ac4
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

picksquash に変えたくなるじゃないですか。でも毎回打つのは面倒ですね。

そこで、それを切り替えるoperator作りました。 初Vimプラグインかも。

operatorにしたのは、複数行を一度に変えたかったから。

使い方

map <buffer> s <Plug>(operator-gitrebase-squash)
map <buffer> e <Plug>(operator-gitrebase-edit)
map <buffer> r <Plug>(operator-gitrebase-reword)
map <buffer> f <Plug>(operator-gitrebase-fixup)

pick と exec はmapしてません。なくても困らないし。

とりあえずvimrcがごちゃごちゃしてきたから切り出しただけなので、てきとーです。