# Neovim: How to use Buffers, Windows and Tabs ver. 2

Last Updated on July 28, 2022 by shibatau

## I. Buffers, Windows and Tabs

Now suppose you have four files in the current directory:

Run the following command in the terminal:

nvim sample1.txt sample2.txt sample3.txt sample4.txt

You can see the buffer 1 in a window:

Run the following command and you can see a list of the four buffers opened.

:ls

Run the following command to split the window:

:split

Now you have created two windows and the buffer 1 is shown in each of the windows.

Run the following command:

:buffer2

Now you have shown the buffer 2 in the second window.

Run the following command:

:vsplit sample3.txt

You have created the third window and shown the buffer 3 in the window.

To be continued.

Now run the following command to create a new tab for sample4.txt:

:tabnew sample4.txt

Let’s show all the tabs:

:tabs

Now you have two tabs. One of them is of three windows and the other has one window:

## II. The commands

#### Buffers

:ls Show all the buffers

:buffer filename To open a file in the list of buffers (you can use Tab key)

:edit filename To open a file in a new buffer

:bufferN (N is buffer number)

:bnext To go to next buffer

:bprev To go back to the previous buffer

#### Tabs

:tabs Show all the tabs

:tabnew file.txt Open file.txt in a new tab

:tabclose Close current tab

:tabnext Go to next tab

:tabprev Go to previous tab

#### Windows

:split filename Sprit window horizontally

:vsplit filename Split window vertically

:new filename Create new window

<Ctrl-w>+c Close a window

<Ctrl-w>+h/j/k/l Moves the cursor to left/bottom/top/right