22

I've got a few tabs open with different window setups.

I'd like to open a new blank buffer in the current window, without having any more splits/windows or tabs

Is there any way to do this?

I know I could do something like :n then C-w j then :q but that seems a bit messy.

Or similar with tabs: :tabe gT :q

I'm slightly confused about the relationship between windows and buffers in general - you can have lots of buffers open without being visible which you can clean up using bd but if they aren't visible then they must be saved, because you can't hide them (using :q) without either saving or discarding changes... that seems a little odd.

23

Hah I should have looked at the help before!

My first instinct was to try :e without any arguments.

I looked at the help for this and a bit further down is

:ene[w]     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.
            If 'fileformats' is not empty, the first format given
            will be used for the new buffer.  If 'fileformats' is
            empty, the 'fileformat' of the current buffer is used.
            {not in Vi}
  • 3
    This help excerpt mentions the 'hidden' option, which may help with some of the oddness you described in your original question. Using :set hidden allows you to hide buffers even if they haven't been written to disk. For me, this setting was the tipping point towards mastering buffer navigation, moving away from a mess of splits and tabs. – tommcdo Mar 28 '15 at 0:18
  • @tommcdo nice one. I'll give that a go – JonnyRaa Mar 28 '15 at 12:06
  • NB: :e with no arguments attempts to reload the file from disk. If you've changed the current file in another editor, this would replace the buffer with what is on disk. Otherwise, if the buffer is modified, you can use :e! to revert to the last saved version. – BallpointBen Jul 30 '18 at 13:50
  • I believe the command is now :enew. – dcow Sep 8 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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