Categories: Web and IT News

Vim split to a specific size

Vim supports two kinds of splits: vertical (:vsplit) and horizontal (:split). You can open any file in a split by calling :split path/to/file or :vsplit path/to/file. By default, the full width or height of the current buffer will be divided in two. The new split will take up 50% of the available real estate, and the existing will be reduced to 50% of its original size.

But! Vim has a way to open splits to a specific size: By prepending a number to a split command, that split will be opened to the exact character width or height you specify. For example: :20 vsplit path/to/file will open a split that is exactly 20 characters wide, instead of 50% of the current width.

Note that the number includes the line numbers, gutter, and bar between buffers. For a vertical split, 4 characters will typically be lost to that space.

You can enter this with or without the space between the number. For example: :30split path/to/file and :30 split path/to/file will do the same thing.

We have written a ton about splits, so be sure to check the archives. Our post about resizing slits will come in handy paired with this tip.

The post Vim split to a specific size appeared first on VimTricks.

Vim split to a specific size first appeared on Web and IT News.

awnewsor

Recent Posts

The Quiet Death of the Dumb Terminal: Why Claude’s New Computer Use Is the Real AI Interface War

Anthropic just made its AI agent permanently resident on your desktop. Not as a chatbot…

11 hours ago

The Billionaire Who Says Your Kids Should Learn to Code Like They Learn to Read — And Why Wall Street Should Listen

Jack Clark thinks coding is the new literacy. Not in the vague, aspirational way that…

11 hours ago

Your AI Chatbot Is Flattering You — And It’s Making Its Answers Worse

Ask a chatbot a question and you’ll get an answer. But the answer you get…

11 hours ago

Google Photos Finally Fixes Its Most Annoying Editing Flaw — And It’s About Time

For years, cropping a photo in Google Photos has been an exercise in quiet frustration.…

11 hours ago

The Squeeze Is On: How U.S. Sanctions, OPEC Politics, and a Shadow War Are Reshaping Global Oil Markets

OPEC’s crude oil production dropped sharply in May, and the reasons stretch far beyond the…

11 hours ago

Google’s Gemini Is About to Know You Better Than You Know Yourself — And That’s the Whole Point

Google is making its biggest bet yet on the idea that artificial intelligence should be…

11 hours ago

This website uses cookies.