Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make VIM create a new window below the current as default?

Tags:

vim

VIM create new window above the current or on the left side as default. To use VIM more naturally, I want it to work oppositely, and I have set

:set splitright
:set splitbelow

This works when I split a window using command

:split

or

:vsplit

However, this fails when I create a new empty window using command

:new

or

:vnew

Is there any solution for the second situation?

like image 705
Wray Zheng Avatar asked Oct 21 '25 11:10

Wray Zheng


1 Answers

You have only to add "below" before the command:

:below new 

:below vnew

and from :help below

:rightb[elow] {cmd}
:bel[owright] {cmd}

Execute {cmd}. If it contains a command that splits a window, it will be opened right (vertical split) or below (horizontal split) the current window. Overrules 'splitbelow' and 'splitright'. Doesn't work for |:execute| and |:normal|.

For the mapping discussed in the comments you can use this one:

:cnoremap new ^Bbelow ^Enew

you get:

^B by typing ctrl+v ctrl+ b

^E by ctrl+v ctrl+ e

like image 200
Meninx - メネンックス Avatar answered Oct 23 '25 08:10

Meninx - メネンックス