Removing gVim Right and Bottom Borders

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.

Success

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 is the author of Advanced Microservices and is a prolific public speaker with a passion for reducing complex problems into simple language and diagrams. His career includes working at Fortune 50's in the Midwest, co-founding a successful startup, and everything in between.