1

Here's what I did

  1. Open a file with :e file1.txt
  2. Open another file with :e file2.txt
  3. Open another file in a split with :vs file3.txt

What I want to do next is to go to file1.txt in full window

So, tried switching to file1.txt buffer by using :buf 1 command.

But it switches the buffer on split and now I have file1.txt and file2.txt in a split window.

How can I switch to last buffer in full window, the way I opened it in the first go ?

1 Answer 1

1

The easiest way to go back to full screen is to use the :only command.

(It's also possible to use the CTRL-W o keystroke or CTRL-W CTRL-O, which is equivalent.)

For what you request (open file1.txt full screen), you'll need the two separate commands. You can run both together using a | as a command separator:

:buf 1 | only

(Or the other way around, that should also work if you do :only first, then change buffers.)

If you have pending changes on a file in another window about to be closed by the command, then a simple :only will refuse to close it, but you can use :only! which will force those buffers to be hidden. (When you try to quit, Vim will ask you about the changes in those files, whether you want to write them before quitting.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .