30

I know I can use :new to open a new buffer in a split window (defined by set splitbelow and set splitright).

But how can I just open a new, empty buffer without opening it in a split?

2 Answers 2

37

You can use :enew. See :h :enew:

Edit a new, unnamed buffer. This fails when changes have been made to the current buffer, unless 'hidden' is set or 'autowriteall' is set and the file can be written.

And you can use :enew! to discard unsaved changes in the current buffer.

5

Vim also offers :tabnew, which opens a new, unnamed buffer in a new tab allows you to easily switch between buffers (tabs) using gt and gT. This consumes the full width of the editor, albeit, technically in a different window (in a different tab).

Corrected from romainl's comment

5
  • 5
    Buffer != Tabs (!). Try both :enew and :tabe while you have a file that you have not saved. However I still upvote this, as it is the tab equivalent to :enew
    – hgiesel
    Commented Jun 13, 2016 at 17:23
  • 2
    :tabnew is the tab page equivalent of :enew.
    – romainl
    Commented Jun 13, 2016 at 20:17
  • Thanks, @romainl! Actually, though :tabe with no argument behaves the same.
    – jpaugh
    Commented Jun 13, 2016 at 20:23
  • 2
    A side effect. Never bet on side effects.
    – romainl
    Commented Jun 13, 2016 at 21:35
  • @romainl :-) For a script, yes; but for everyday use? I'd prefer using a smaller subset of commands --- so that I can remember them all.
    – jpaugh
    Commented Jun 13, 2016 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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