How do I move around and otherwise rearrange splits in vim?

42

11

So far, I've figured out swapping splits laterally via CTRL+W x, and that's pretty much it.

How do I move a split anywhere in a viewport that contains multiple vertical and horizontal splits?

How do I create a horizontal split that, say, spans the entire top half of the screen after I have already opened a few vertical splits? (Currently, when I create a new horizontal split in an already-vertically-split viewport, I get a horizontal split in one of the columns.)

Perhaps most vim users prefer tabs over splits, but I really like the latter because I work on a 30" monitor! :-)

hakanensari

Posted 2010-12-06T14:18:04.970

Reputation: 1 567

Answers

34

I suggest you read through the help file for vim windows. The specific sections of that file that apply to your question:

:help opening-window
:help window-moving


Edit: I can only assume this is periodically getting downvotes because I haven't provided specific answers here. The problem is that the original poster asked several questions, and they were broad. The best way to answer all those questions at once is to refer to the Vim documentation, which should always be available wherever Vim is installed.

Also I want to note that I didn't just tell the OP to "RTFM," I provided specific sections of the manual to read, which can be an acceptable answer.

Heptite

Posted 2010-12-06T14:18:04.970

Reputation: 16 267

1@Danny Why make SO the manual? The manual should be the manual; you check that, and, if you don't find your answer there, you come to SO with your question. There's no need to duplicate the info in the manual here. – DBedrenko – 2014-08-11T08:31:56.823

2@NewWorld because SO has hundreds of thousands of devs editing, adding, commenting, making it awesome ;) – Danny – 2014-08-11T18:31:21.287

3@Danny i.e. spoonfeeding. The documentation is great and the answer is there; there's no need to unnecessarily duplicate information. – DBedrenko – 2014-08-13T08:37:22.463

1@NewWorld well now you're thinking too much like a programmer! – Danny – 2014-08-13T13:49:08.303

11

see: http://superuser.com/help/how-to-answer

"Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline."

– j03w – 2014-10-03T04:56:41.127

1I find SO silly with its downvotes for helpful answers, I very seldom use advice or give on SO – peterretief – 2016-09-11T14:39:00.600

72RTFM doesn't answer the question. – poindexter – 2012-10-02T15:54:37.063

1@poindexter Could you be more specific about what you don't understand in the documentation? The OP marked my answer as accepted, so it did answer his question. I know the Vim documentation can be a bit terse and hard to understand at first, but it's the best place to go to for answers if you know what to look for. – Heptite – 2012-10-03T18:32:58.313

13we expect SO to be the manual...it's easy: google for something, open the SO link and get what you came for, without being redirect to another source. – Danny – 2013-05-30T18:58:17.757

60

I'm sure the help file covers it, but to move a split to cover the top of the screen, you can do CTRL-W K (i.e., Ctrl+W Shift+K), with H = left, J = bottom, K = top, L = right (following usual vi/vim conventions).

Note that the letters are uppercase. CTRL-W k (i.e., Ctrl+W K, without Shift) will instead move up between splits, etc.

Henrik N

Posted 2010-12-06T14:18:04.970

Reputation: 1 276

16

You can do:

:to sp

or

:top split

to do a horizontal window that spans the top of the screen.

Paused until further notice.

Posted 2010-12-06T14:18:04.970

Reputation: 86 075

Thanks both to you and the other poster who gave the first half of the answer. – hakanensari – 2010-12-06T22:31:12.777

Upvote for answering the question, it'd be nice to see this answer combined with Heptile's. – poindexter – 2012-10-02T15:55:04.927