So, you want to open two files in vim?
Fernando Tricas García

Fernando Tricas García @fernand0

About: El mundo es imperfecto. Puedes hacer algo para mejorarlo. O no. Puede que lo consigas. O no.

Location:
Zaragoza, Spain
Joined:
Mar 6, 2020

So, you want to open two files in vim?

Publish Date: Feb 9 '21
1 2

I'm preparing some shellscripts to avoid repetition of some usual tasks. Some of them involve opening a file and then using the :split command in vim.
Is it possible open two files like this from the command line?

Indeed, it is, you can use the vim -o file1 file2 command. In this way vim will show the two files in split view, the first one in the upper section and the second one in the bottom section.

Comments 2 total

  • Ben Sinclair
    Ben SinclairFeb 9, 2021

    You can also use -O for vertical splits, and if you omit either flag (and presumably have hidden set), you will open them in hidden buffers, so you can navigate with :ls, :b <n> and :next and so on.

    You can open all your buffers in splits at any time with the best command in Vim: :vertical ball.

    • Fernando Tricas García
      Fernando Tricas GarcíaFeb 9, 2021

      Nice, thanks. For thist matter I prefer using horizontal split but sometimes vertical is useful also.

Add comment