Reset terminal after quitting VIM -- colors all messed up

5,516

Solution 1

I was having a similar problem with Vim + GNU Screen + Terminal.app. Here was my solution:

Create a script called resetcolor:

#!/bin/bash

echo -ne "\033[0m"

Put this script in your PATH.

Then within ~/.vimrc, add the following:

au VimLeave * !resetcolor

Based on this answer.

Solution 2

Since the reset command should have reset all terminal settings, including color, I'm thinking that your terminal software is bad, and is therefore also probably responsible for the color bug in the first place.

(This, of course, assumes that your TERM environment variable is set to an appropriate type for your terminal software.)

Solution 3

Make sure your TERM environmental variable is correct for your terminal emulator software. People often set it to arbitrary values that seem to work without realizing that it can cause them problems.

Share:
5,516

Related videos on Youtube

davidu
Author by

davidu

Updated on September 17, 2022

Comments

  • davidu
    davidu over 1 year

    Whenever I quit VIM my terminal colors are all messed up. Manually running reset on the command line doesn't seem to fix it either.

    I'm using the Mustang VIM theme. I think I basically need to tell VIM to reset all colors or something before it quits.

    Any ideas?

    • Admin
      Admin over 13 years
      What terminal software? What is your $TERM?
    • Admin
      Admin over 12 years
      It's set to xterm-256color
    • Admin
      Admin over 12 years
      A screenshot could help to better explain the problem.
  • davidu
    davidu over 12 years
    I think a combination of this answer and @Heptite's are about right. The term software (iterm2) has had some major revisions and the issues have all seemed to go away.
  • n.st
    n.st over 8 years
    You can just add au VimLeave * !echo -ne "\033[0m" to your vimrc, without having to create an external script.
  • sapht
    sapht almost 7 years
    Vim may have drawn over the bottom line if you use a background color, which your prompt will only replace the first part of, replace with !echo -e "\033[0m" to fix (prints a newline after clearing bg color)