Removing gVim Right and Bottom Borders

Support this website by purchasing prints of my photographs! Check them out here.

A gVim window is essentially a terminal emulator, but specifically for rendering a Vim interface. This means the window contains fonts with a specific width and height. When the window is made fullscreen there will end up being a small gap on the right and bottom of the screen. This is because the width and height of the screen is not perfectly divisible by the width and height of a character.

When this happens your window will look something like this:

Unsightly gVim Window Gaps
Unsightly gVim Window Gaps

In this screenshot there is a large white border at the bottom and right of the gVim window. This gap is exasperated in my situation because I've configured my task management bar, tint2, to use the same theme as I use in Vim.

The color of the gap is, unfortunately, something we cannot configure within Vim itself. To fix this we'll need to configure GTK to use a different background color for the application.

Depending on whether your version of gVim was compiled with GTK 3.0 or GTK 2.0 you will need to take a different approach to fix the problem.

To figure out which version of GTK you're using, issue the following command:

$ gvim --version | grep GTK
> Huge version with GTK2 GUI.  Features included (+) or not (-):

In my case I'm making use of GTK 2.

You'll also want to know what the background color of your theme is. In my situation my colorscheme file is located at ~/.vim/colors/hybrid.vim, and the appropriate lines containing the background color looks like this:

if has("gui_running")
  let s:vmode      = "gui"
  let s:background = "#1d1f21"
  let s:foreground = "#c5c8c6"

In this situation the background color of my theme is #1d1f21.

gVim with GTK 2

Edit the file ~/.gtkrc-2.0. Then, append the following to the bottom of the file:

style "vimfix" {
  bg[NORMAL] = "#1d1f21" # theme background color
widget "vim-main-window.*GtkForm" style "vimfix"

Answer taken from miloshadzic.

gVim with GTK 3

Edit the file ~/.config/gtk-3.0/gtk.css and add the following to the bottom of the file:

#vim-main-window {
  background-color: #1d1f21; /*: theme background color */

Answer taken from proprefenetre.


Making the above changes will not immediately change the rendering of open gVim windows. For the changes to apply you'll need to launch a new instance of gVim (no logout necessary). Once you've started a new gVim instance your window should look like the following:

Appealing gVim Without Gaps
Appealing gVim Without Gaps

Thomas Hunter II Avatar

Thomas has contributed to dozens of enterprise Node.js services and has worked for a company dedicated to securing Node.js. He has spoken at several conferences on Node.js and JavaScript and is an O'Reilly published author.