vim colours change slightly in xterm when a key is pressed
Hi,
I'm having a problem with vim and xterm. When I open a file and press any key, the colour scheme changes slightly. This doesn't happen if I run a 256-colour xterm (export TERM='xterm-256color') but if TERM is set to 'xterm' (the default) I see the colour change. Setting TERM='xterm-256color' in my ~/.bashrc is a "solution", but I'd rather not have to do that since it's never been necessary in the past (e.g., on 13.1) and I don't use any 256-color schemes for vim (usually just the default or possibly "delek"). It doesn't happen with rxvt or with Xfce's terminal. I've tried compiling some other versions of xterm but they either exhibit the same behaviour or don't build. I have tried running without any ~/.vimrc file just to be sure it wasn't one of my settings and I've also tried the sample file at /usr/share/vim/vimrc; the effect is the same. Can anyone else confirm this issue? Is there a solution besides running a 256-colour xterm? Thanks in advance for any help with this. |
Yeah, I notice it here too. It's obnoxious. After looking at the escape codes it sends to the terminal, I'm blaming vim. (Hint: Run `script`, open vim and trigger the bug, then quit vim and `exit`. Look at the typescript file in a hex editor.)
On xterm it does this: 1. Draws the column of ~ in bold blue (escape code "\e[1m\e[34m") 2. Queries xterm for several items. I guess this is where it figures out that xterm can support more colors. 3. On the first keypress, redraws the column of ~ in a different shade of blue (escape code "\e[94m") It doesn't even try step 2 with rxvt. Seems like step 2 should be before step 1. |
Thanks for the information.
As a temporary workaround, I've added the following to my ~/.bashrc: Code:
case "$TERM" in |
I'm trying the following workaround right now, no problems yet.
Add this to your ~/.Xresources: Code:
XTerm*termName: xterm-256color Now if you start xterm it should set $TERM to xterm-256color, and now vim should work fine. But... for some reason it doesn't set $TERM correctly. Appears that xterm checks for "xterm-256color" in termcap instead of the more modern terminfo, and since it's not there by default, it falls back to using "xterm". So I added xterm-256color after xterm-color in /etc/termcap like this. I don't know if it's correct, but it seems to work okay so far. Code:
vs|xterm|xterm-color|xterm-256color|vs100|xterm terminal emulator (X Window System):\ |
Quote:
In the end, I decided to go with the alias workaround I posted last night, TERM=xterm (default), and the original /etc/termcap. I'm still not sure which solution I prefer. With regard to xrdb, I generally use -merge instead of -load, just to be on the safe side. |
vim in xterm: cursor jumps over words in addition to colour changes
In my case colour changing behaviour is accompanied with an additional quirk.
If edit a line that contains the following : Code:
"Xft:v1:antialias=true" Both the erratic cursor positioning and the colour changes happen in XFCE and FVWM.2.6.1 (in extra). Neither this erratic cursor positioning nor the colour changes happen when trying vim under rxvt in either window managers. I haven't tried the workarounds presented here... I just found this topic... |
Quote:
Code:
if &term =~ "xterm" |
Well, setting t_Co to 256 solved the "changing colors" syndrome, but had not effect on the erratic cursor movement I have as described in http://www.linuxquestions.org/questi...6/#post4349599
I have to add that if I navigate using the h,j,k,l keys instead of the arrow keys then the erratic behavior is not observed. Could it be an xorg issue? I have the following in /etc/X11/xorg.conf.d/90-keyboard-layout.conf : Code:
Section "InputClass" I should also add, that for the last 10 years or so I have the following .Xdefaults entries for xterm: Code:
xterm*background: black |
Quote:
|
Nothing to worry about. My response was to the thread.
About the erratic cursor movement, it must be something else. I have also trouble with the "Home" key in the rxvt command line. I don't really understand the situation. I have the same settings for .Xdefaults and xorg.conf for the last 10-12 years or so. The only time I had queer issues like these, was when the keyboard model was faulty recognised, only it's been a *long* time that had happened. |
Thanks for all the replies.
I'm going to mark this thread [SOLVED] since there are some good workarounds for the problem presented here. (They are easier than rebuilding/upgrading vim. ;)) |
writing set term=xterm-256colors in .vimrc also works for me
|
I noticed the color changing again after testing out 14.0, so I'm looking for a better solution. This time I'm going to blame xterm. Here's what happens:
So I think the solution is to prevent xterm from lying about what it supports. It should set $TERM to xterm-256color if it's going to report that it supports 256 colors. Recompiling xterm with Code:
--disable-full-tgetent --with-terminal-type=xterm-256color Also I noticed that rxvt identifies itself with $TERM="xterm". It doesn't respond when vim asks how many colors it supports, so you get 8 colors. Recompiling rxvt with Code:
--enable-256-color --with-term=rxvt-256color Code:
:runtime syntax/colortest.vim |
All times are GMT -5. The time now is 12:43 AM. |