Fix: Vim not scrolling, coloring or displaying text correctly when using GNOME Terminator

  • Print
  • PDF
Pinterest

Terminator and vimI recently installed GNOME Terminator as a replacement for the default terminal emulator on my Linux installation, due to its great ability for easy and quick screen splitting (among other features). However, when I would try to use vim from within one of the terminator screens, vim would not function properly. It would either not display the file’s content at all, or when I would scroll it would exhibit very bizarre behavior, not updating the screen with the correct content (like getting stuck at the bottom or showing an incorrect line offset), or coloring the text incorrectly (e.g., black text on a black background). Searching online suggested that the problem had to do with ncurses and .terminfo, but this was not the case. The problem was with one of my configuration settings in my .vimrc file.

For me, the problem was that I had the following line in my .vimrc file, which I use to automatically set my gvim window to the specified size whenever the program starts:

set lines=50 columns=120

Normally, this setting will not cause a problem because it will only apply itself when using gvim (i.e., where gvim can actually change the window size) and gets ignored when using only vim. However, for some reason when using GNOME Terminator, it attempt to set the vim window size, while keeping the Terminator window size unchanged. This caused all of the text coloring and scrolling problems. I didn’t want to get rid of this vim setting, though, because I like my gvim window to be a particular size. You can get around this problem by updating your .vimrc file to include an "if" statement to check if you are using vim or gvim. The updated code is shown here:

if has("gui_running")
    set lines=50 columns=120
endif

While you’re in there, this is also a great opportunity to conditionally change the text coloring if you are like me and prefer to use a light background in gvim and a dark background in vim. By telling vim/gvim what type of background color (e.g., "light" or "dark") you are using, it will automatically adjust the syntax coloring and spell check highlighting for better visibility. You can do this by updating the code above to also set the background color type using the "bg" parameter as follows:

" Settings based on whether using vim or gvim...
" gvim
if has("gui_running")
    set lines=50 columns=120
    set bg=light

" vim
else
    set bg=dark
endif
Pinterest
  • Digg
  • StumbleUpon
  • Reddit
  • PDF
  • Print

One thought on “Fix: Vim not scrolling, coloring or displaying text correctly when using GNOME Terminator”

Leave a Reply

Your email address will not be published. Required fields are marked *