Suppose I have some files in a folder. I browse the folder using vim vim myfolder. It opens netrw with a list of the files in the directory. Now I want to select two or more files and then open them in comparison mode. How can I do that?

  • 1
    Did you look at the documentation...:help vimdiff? The answer is right at the beginning...:help start-vimdiff
    – B Layer
    Apr 19, 2021 at 6:20
  • @BLayer Did you read my question? I saw nothing in the begining, it speaks about command line like vimdiff file1 file2, but I'm speaking about exploring the files and then opening them side by side. My main problem is that the filenames are long and I someway need to select them in browser window.
    – Ahmad
    Apr 19, 2021 at 7:12
  • 3
    Your question is actually hard to understand. There are hundred ways to open two files in vertical splits. But there's no such thing as "vim browser". If you mean netrw then you should read :h netrw. If it's another plugin then read its documentation and so on. Next, you were adviced to read :h vimdiff but it looks you never got after first few lines. At least, do the first section until the end before complaining that someone haven't answered your question.
    – Matt
    Apr 19, 2021 at 7:30
  • 2
    Open the files as usual in whatever window layout you need. Once you have all files you'd like to diff open, use :windo :diffthis Apr 19, 2021 at 7:38
  • @ChristianBrabandt I don't know the first part actually, how I open two files in vim by selecting their name... (not using command line)
    – Ahmad
    Apr 19, 2021 at 7:47

1 Answer 1


When you opened the folder using vim, vim thefolder

  • navigate to each file using arrow keys and press mf, it marks the files,
  • then press md, it calls vimdiff on the selected files (up to 3 files).

There are other commands in this mode, use :h netrw to find more

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.