How do I open a blank new file in a split in Vim?

103

14

Must be something super obvious, but I can't figure out, and Google is not helping out either.

hakanensari

Posted 2010-11-18T10:33:18.610

Reputation: 1 567

Answers

132

:help new
:help vnew

should bring you on course.

you will have a new buffer then, obviously. that buffer becomes a file only if you :w it to the disk.

akira

Posted 2010-11-18T10:33:18.610

Reputation: 52 754

3Also :set splitbelow is the corresponding command to make the new split appear on the bottom when splitting horizontally. – dsaxton – 2016-04-22T14:10:05.410

6And :set splitright puts the new split on the right. Awesome, thanks – hakanensari – 2010-11-18T13:56:31.367

51

another way is to do a <CTRL + W> n in normal mode. This will create a new split.

EDIT:

You can also do <CTRL + W> v in normal mode to create a vertical split (the previous one will do a horizontal split.

And just to be complete, you move to the different splits by doing <CTRL + W> <direction> with the direction being any h, j, k, or l

To close a buffer, do <CTRL + W> q

g19fanatic

Posted 2010-11-18T10:33:18.610

Reputation: 1 251

fyi: these open the current buffer in a new split, not a new file in a new split. – Emile 81 – 2017-05-10T08:44:34.230

2For me, Ctrl+w n opens a split with a new buffer, but Ctrl+w v just splits the current buffer. Strange. – c24w – 2017-08-04T08:46:18.850

1

if you're looking to create a vertical split with a new file, check out this question/answer https://vi.stackexchange.com/questions/2811/vertical-equivalent-of-controlw-n

– g19fanatic – 2017-08-04T11:42:27.527

3

vim myfile.txt  # open one file in one window
:buffers        " shows one buffer with "myfile.txt" in it
:sp             " create split window; we now have one buffer with two windows.
:e newfile.txt  " create new buffer with new filename in first window
:buffers        " shows two buffers (myfile.txt & newfile.txt), each in own window

This is a good link: http://vim.wikia.com/wiki/Easier_buffer_switching

edW

Posted 2010-11-18T10:33:18.610

Reputation: 131

0

I used the Vim menu under File - Split Open. You will have to give a name for your new blank file though.

Rolnik

Posted 2010-11-18T10:33:18.610

Reputation: 1 457

Vim has a menu? – frabjous – 2010-11-18T16:23:23.813

gvim or macvim are able to display a menu, yes. what did you expect? :) – akira – 2010-11-18T16:26:21.177

It seems that :sp also can work -- for those not using the gvim version. – Rolnik – 2010-11-18T18:58:56.593