Search code examples
vimvimdiff

Delete the same line in multiple VI windows


I love using vim and vimdiff. I am currently working on comparing two files in vimdiff and I frequently run into the situation that I want to delete the same line in both buffers. In the following example I would like to delete lines 40 and 41.

39 text_a  |   39 text_b
40 text_aa |   40 text_aa
41 text_bb |   41 text_bb
42 text_c  |   42 text_d

It feels tedious to perform dd Ctrl-W-W, dd Ctrl-W-W to delete the line in the current window, jump to the other window, delete the line there and jump back to my original window.

Does anyone know a shortcut for this?


Solution

  • You can use bufdo to delete lines 40 and 41 in all buffers

    :bufdo 40,41d 
    

    as per your case using vimdiff, the command is

    :windo 40,41d