LoginSignup
4
5

More than 5 years have passed since last update.

vimgrepで、conflict起こした時の手動修正を楽にする

Last updated at Posted at 2015-02-13

前提知識

前提知識と参考URLを以下に。

背景

remoteにpushする時は、親ブランチにrebaseしてからpush!
でも親ブランチから切ってから間隔空くと、盛大にconflict起こすこともしばしば。
複数ファイルでconflictが起きたら、一つ一つのファイルを自分で開くのが面倒なので、そんな時のTips。

本題

  1. vim起動。
    $ vim hoge.txt

  2. vimのコマンドラインモードから、vimgrep使う。
    :vim /^<\+\sHEAD$/ ./** | cw

  3. [Quickfixリスト]にconflictしたファイル一覧とその該当箇所が表示される。

  4. :cnext, :cpreviousでファイル間を移動して、conflictを解消していく。

何やってるかというと、vimgrepの正規表現で、
<<<<<<< HEAD
を検索して、Quickfixリストに入れてます。

終わりに

vimから出なくて良いので、楽っす。
vimrcにalias入れとくのがオススメです。

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5