1

How can I create new window with new buffer in vim, vertical with shortcuts? (Similar to Ctrl-w n, but vertically.)

1
  • 1
    Inverse of the action? Or reverse of the window split whilst keeping the buffer? Or split in the opposite direction? Or split in the perpendicular direction? Commented Jan 2, 2020 at 9:20

1 Answer 1

8

The Ctrl+Wn shortcut is the same as the newcommand. There is also a vnew command that works exactly as new, but splits vertically. To use it, type Esc:vnewEnter.

You could also remap e.g. Ctrl+Wv from doing the equivalent of vsplit (the default) to vnew using something like

noremap <C-w>v <esc>:vnew<cr>

in your ~/.vimrc file.


Note: When the below answer was written, the question asked for the "contrary" action to Ctrl+Wn. I interpreted this as "the opposite of splitting and creating a new window, i.e. closing a split window".

The q command closes the current buffer (this would be entered as Esc:qEnter). If that is done in one of the buffers that you get from splitting, you will get back to an editor window containing only a single buffer, reversing the effect of Ctrl+Wn.

You may also use Ctrl+Wq for doing this.

5
  • Thanks and sorry for my english!! Commented Jan 3, 2020 at 0:26
  • But you have mapped "ctrl-w v" which is used to divide the screen vertically but WITHOUT new buffer ... Of DEFAULT, there is no shortcut for ":vnew"? Commented Jan 3, 2020 at 0:27
  • For config file using lua: vim.keymap.set('n', '<C-w>v', '<esc>:vnew<cr>', { noremap = true}) Commented Jan 18, 2024 at 5:21
  • @FanchenBao I suppose that would be for NeoVim, not Vim, right? Commented Jan 18, 2024 at 8:37
  • Yes, for NeoVim. I should've specified it in the comment. Commented Jan 18, 2024 at 20:32

You must log in to answer this question.