How make Vim fill Terminal window
Asked Answered
B

5

21

When running Vim in a Terminal, the vim window does not fill the entire screen space, which is very irritating when the terminal background color radically differs from vim's. Admittedly, one might want to keep them somewhat in sync, but given that I don't want that, how can I make vim stretch across the entire window? The screenshot below illustrates the problem.

enter image description here

Bestead answered 14/11, 2014 at 19:33 Comment(0)
R
4

It looks like your terminal allows resizing in increments less than a single row/column.

Vim, on the other hand, draws only complete rows or columns. The partially visible rows/columns in the terminal are therefore not being drawn when Vim displays its window.

Rede answered 14/11, 2014 at 19:54 Comment(2)
Hm, that is bad since I want to use it in fullscreen. I suppose it's not possible to tell vim how many pixels a column should have, is it?Bestead
Btw. the resizing has nothing to do with it. If I resize the window, the borders stay the same, so that can't be it.Bestead
W
5

You have only two solutions:

  • give your terminal emulator's background and Vim's background the same color,

  • or remove Vim's background color.

Vim, your shell and every command-line program divide the screen in a grid of which every cell is the size of a character. If the GUI window's size in pixels doesn't fit your shell's grid size you get that ugly padding.

Example:

  • my cell size is 7x19 and my display is 1680x1050,
  • I can fit 240 columns and 55 lines but I will always have a 5 pixels padding at the bottom of the screen.

Additionally, most terminal emulators add a default padding around the usable screen to increase legibility so you will never be able to make Vim really full screen when run in a terminal emulator.

Widmer answered 14/11, 2014 at 20:39 Comment(6)
One would think this is an obvious problem and therefore would have been addressed somehow. Very depressing.Bestead
"One would think this is an obvious problem and therefore would have been addressed somehow." I would think it's the result of using terminals and command-lines and that it's a non-problem and would concentrate on something else. Try using X-Windows or a native version of vim or change your font-size.Romano
Almost everybody uses a terminal, so I don't see how it's a non-problem. Changing the font size does not help.Bestead
It's a non-problem because adjusting the background color of your terminal emulator window is trivial. That's what "everybody" who faces that "problem" does and that's what you should do too. If you think it's too much of a hassle, go ask iTerm's developer to remove its huge default padding and explain him that he should distort its display just to avoid that hassle of yours. I'm sure "everybody" will thank you for that.Widmer
Just wondering, would it be possible to change the background color of the terminal emulator automatically when vim opens (or better, on autocmd colorscheme *)? This does seem frustrating.Armchair
@Yosh, probably. One would have to find a way to do that for every terminal emulator for such a thing to be considered a solution, though. On Mac OS X, both iTerm.app and Terminal.app make their background color setting available via AppleScript so it sounds very doable but I'm not sure about other terminal emulators on other platforms. I won't do it so you are welcome to give it a try.Widmer
R
4

It looks like your terminal allows resizing in increments less than a single row/column.

Vim, on the other hand, draws only complete rows or columns. The partially visible rows/columns in the terminal are therefore not being drawn when Vim displays its window.

Rede answered 14/11, 2014 at 19:54 Comment(2)
Hm, that is bad since I want to use it in fullscreen. I suppose it's not possible to tell vim how many pixels a column should have, is it?Bestead
Btw. the resizing has nothing to do with it. If I resize the window, the borders stay the same, so that can't be it.Bestead
P
2

I've recently written a Medium article which could help solving this issue visually. Link.

One way to go about this is by triggering a change in your terminal's background color when Vim is running. This makes use of escape sequences and terminal colors, which might not be available in your terminal emulator.

change_terminal_background() {
 local COLOR="$1"

 if [ "$TERM" == "screen-256color" ]; then
# TMUX
  echo -ne "\\ePtmux;\\e\\033]11;$COLOR\\007\\e\\\\"
 else
#  NOT TMUX
  echo -ne "\\033]11;$COLOR\\007"
 fi
}

Call it like this:

vim() {
# Change the terminal's color when Vim starts
  change_terminal_background "#924560"

  /usr/bin/vim "$@"

# Change it back when it exits
  change_terminal_background "#000000"
}
Presley answered 20/10, 2018 at 8:5 Comment(0)
L
0

You can use my plugin vim-pedant to automatically update iterm2's palette to match vim's colorscheme.

Longhand answered 24/4, 2017 at 3:55 Comment(1)
This does not seem to answer the question. Or rather, it is an intrusive workaround at best.Bestead
G
-3

It's not that VIM isn't filling the screen; it is. What you're seeing is the help text. The help text is centered. Once you go into insert mode or run a command it goes away.

Gallice answered 14/11, 2014 at 19:36 Comment(1)
oarfish is talking about the different colors on the bottom and right sides of the terminal.Rede

© 2022 - 2024 — McMap. All rights reserved.