Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I have a file with the name First.txt, which I opened that by vim. Now I want to go another file which its name is Second.txt .

  1. How to open Second.txt while I do not close First.txt.

  2. How to switch between them First.txt and Second.txt on the vim?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

You can open a different file in vim with the :o command, like so:

:o /file/To/Open  

This closes your current file and opens /file/To/Open.

As of vim 7.0 you can use the tabs feature to open multiple files at once. Use vim's :tabnew command to open a new tab:

:tabnew [filename]  

Where [filename] is an optional file to open in the new tab.

To switch between tabs use any of the following commands:

  • :tabn - switches to the next tab.

  • :tabp - switches to the previous tab.

  • gt - toggles through all tabs, from left to right.

  • :tabfirst - switches to the first tab.

  • :tablast - switches to the last tab.

You can also pass multiple files to vim and have it open them in different tabs like so:

vim -p file1 file2 etc  

For more tab related info see Vim tips: using tabs on

share|improve this answer
or just :tabe [filename] instead of :tabnew [filename] –  vusan Jul 22 at 11:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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