vimtricks.wiki Concise Vim tricks, one at a time.

How do I open a new empty buffer in a horizontal split without opening any file?

Answer

<C-w>n

Explanation

<C-w>n creates a new empty buffer and opens it in a horizontal split above the current window. The new buffer has no name and no contents — it is a blank scratch pad ready for you to type into or paste content from registers and shell commands.

How it works

  • <C-w> — the window command prefix
  • nnew empty buffer in a split
  • The new window is placed above the current window and receives focus
  • The buffer is unnamed ([No Name]) until you write it with :w filename
  • The equivalent Ex command is :new (horizontal split) or :vnew (vertical split)

Example

You want a quick scratch space to paste and reorganize yanked lines:

<C-w>n          " open empty split
"0p             " paste last yanked text into the scratch buffer
Go              " append more content
:w notes.txt    " save when you are done

Tips

  • For a vertical empty split, use :vnew (there is no direct <C-w> shortcut)
  • To open a specific file in a new split, use :new filename or :split filename
  • The scratch buffer is not associated with any file on disk — closing it without saving discards the content (Vim will warn you if hidden is not set)
  • Combine with :r !command to capture shell output into the new buffer:
    <C-w>n
    :r !git log --oneline -20
    

Next

How do I run a search and replace only within a visually selected region?