I'd been using Linux Mint MATE for years, and recently moved to Arch Linux with MATE Desktop Environment without any change of hardware or .vimrc. (By the way, I use no plugin.) After that, when I open a file on vim and

  • scroll up/down

  • or, minimize the window and un-minimize it later

  • or, use "show deskop" functionality and then unuse it

, the screen is sometimes be corrupted in a way that the same lines are apparently duplicated. This has never occurred on Linux Mint on the same machine, and Linux Mint on MacbookPro.

For example, the first picture is a healthy state without any corruption.

enter image description here

The opened file consists only of ASCII characters (with UTF-8 encodings) and short enough not to cause memory problems. This screen can sometimes be (corruptions are underlined):

enter image description here

enter image description here

Pressing Ctrl+L to redraw the display solves the problem, but it is really annoying.

What is bad is that I don't know when it occurs. So I cannot reproduce the problem to debug or find the cause.

What I tried is

  • uninstall Arch's original vim and compile vim from the official source, because I did so also on Linux Mint

  • do some gpu settings

  • unset TERM, COLORTERM or try many values of them according to scrolling is messed up and Vim NerdTree corrupts when using Tmux (NOTE: I do not use tmux or screen.)

  • change HDMI-cable to a quality one

  • change startup command bound to mate-terminal from the default bash to env TERM=xterm bash

  • unset cursorline

  • change terminal emulator from mate-terminal to gnome-terminal

  • :set term=builtin_term (see help builtin-terms)

  • :set nottybuiltin (this made the frequency of occurrence larger)

  • reinstall everything including the OS (It seems the problem has been solved. But I'm still checking whether it really has. Still occurs.)

  • unset cursorline (This worked like a charm. Now it seems the problem quite very rarely (but still) occurs. After a week or so, I'll append if the problem has really been solved or not.) (As @Rich pointed out, I had already tried this before. At that time, unsetting the options didn't work well. Perhaps this difference comes from the difference of versions...) No. Still occurs.

  • refine compile options (see below) -> It seems the problem is solved. I haven't observed it for more than two months.

What I don't want to do is

  • change font

  • change desktop environment

Does anyone have an idea why that occurs? I really want to solve the problem.


I'll add any information if required.

#This is the information at the time I posted this question.
#Please scroll down to see the lastest information.

~ $ neofetch
OS: Arch Linux x86_64
Kernel: Linux 5.3.5-arch1-1-ARCH
Shell: bash 5.0.11
Resolution: 1920x1080 @ 60.00Hz
Terminal: mate-terminal
CPU: Intel i5-7500 (4) @ 3.8GHz [39.0°C]
GPU: NVIDIA GeForce GTX 1050 Ti
Memory: 1405MiB / 15978MiB [=--------------]
CPU Usage: 2% [---------------]
Locale: en_US.UTF-8 

~ $ vi --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct  4 2019 02:04:19)
Included patches: 1-2109
Compiled by me
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl               -farsi             -mouse_sysmouse    -tag_any_white
+arabic            +file_in_path      +mouse_urxvt       -tcl
+autocmd           +find_in_path      +mouse_xterm       +termguicolors
+autochdir         +float             +multi_byte        +terminal
-autoservername    +folding           +multi_lang        +terminfo
+balloon_eval      -footer            -mzscheme          +termresponse
+balloon_eval_term +fork()            +netbeans_intg     +textobjects
+browse            +gettext           +num64             +textprop
++builtin_terms    -hangul_input      +packages          +timers
+byte_offset       +iconv             +path_extra        +title
+channel           +insert_expand     -perl              +toolbar
+cindent           +job               +persistent_undo   +user_commands
+clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +virtualedit
+cmdline_hist      +langmap           +python/dyn        +visual
+cmdline_info      +libcall           +python3/dyn       +visualextra
+comments          +linebreak         +quickfix          +viminfo
+conceal           +lispindent        +reltime           +vreplace
+cryptv            +listcmds          +rightleft         +wildignore
+cscope            +localmap          -ruby              +wildmenu
+cursorbind        -lua               +scrollbind        +windows
+cursorshape       +menu              +signs             +writebackup
+dialog_con_gui    +mksession         +smartindent       +X11
+diff              +modify_fname      +sound             -xfontset
+digraphs          +mouse             +spell             +xim
+dnd               +mouseshape        +startuptime       +xpm
-ebcdic            +mouse_dec         +statusline        +xsmp_interact
+emacs_tags        +mouse_gpm         -sun_workshop      +xterm_clipboard
+eval              -mouse_jsbterm     +syntax            -xterm_save
+ex_extra          +mouse_netterm     +tag_binary        
+extra_search      +mouse_sgr         -tag_old_static    
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.
0/include -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi
-3.2.1/include -I/usr/include/harfbuzz -I/usr/include/fribidi -I/usr/include/freetype2 -I/usr/include/li
bpng16 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmoun
t -I/usr/include/blkid -I/usr/include/atk-1.0 -pthread    -g -O2 -D_REENTRANT  -U_FORTIFY_SOURCE -D_FORT
Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -l
atk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuz
z -lfontconfig -lfreetype  -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lelf -lnsl    -l
canberra  -lacl -lattr -lgpm -ldl           

#Here is the lastest information.

~ $ neofetch
OS: Arch Linux x86_64 
Kernel: Linux 5.5.2-arch1-1 
Shell: bash 5.0.11 
Resolution: 1920x1080 @ 60.00Hz 
Terminal: gnome-terminal 
CPU: Intel i5-7500 (4) @ 3.8GHz [25.0°C] 
GPU: NVIDIA GeForce GTX 1050 Ti 
Memory: 2175MiB / 15978MiB [==-------------] 
CPU Usage: 9% [=--------------] 
Locale: en_US.UTF-8 

~ $ vi --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Feb  9 2020 11:55:29)
Included patches: 1-235
Compiled by me
#(Contents below are exactly same as the above ones except `+popupwin` (this functionality was added in version 8.2).)

By the way, I'm not experiencing the problem other than on vim (until today). less and any GUI applications like firefox work well.

Additional information:

This is the value of TERM.

~ $ echo $TERM

This is the output of :pu =execute('set termcap').

--- Terminal codes ---
  t_AL=^[[%p1%dL      t_DL=^[[%p1%dM      t_mr=^[[7m          t_se=^[[27m         t_u7=^[[6n
  t_al=^[[L           t_dl=^[[M           t_ms=y              t_Sf=               t_ue=^[[m
  t_bc=               t_EC=^G             t_nd=^[[C           t_SH=^[[%p1%d q     t_us=^[[4m
  t_BE=^[[?2004h      t_EI=               t_op=^[[39;49m      t_SI=               t_ut=y
  t_BD=^[[?2004l      t_fs=^G             t_RF=^[]10;?^G      t_Si=^[[22;1t       t_vb=
  t_cd=^[[J           t_GP=^[[13t         t_RB=^[]11;?^G      t_so=^[[7m          t_ve=^[[?25h
  t_ce=^[[K           t_IE=^G             t_RC=^[[?12$p       t_SR=               t_vi=^[[?25l
  t_cl=^[[H^[[2J      t_IS=^[]1;          t_RI=^[[%p1%dC      t_sr=^[M            t_VS=^[[?12l
  t_Ce=               t_ke=^[[?1l^[>      t_Ri=^[[23;1t       t_ST=^[[22;2t       t_vs=^[[?12h
  t_Co=256            t_ks=^[[?1h^[=      t_RS=^[P$q q^[\     t_Te=^[[29m         t_xn=y
  t_CS=               t_le=^H             t_RT=^[[23;2t       t_TE=^[[>4;m        t_xs=
  t_CV=               t_mb=^[[5m          t_RV=^[[>c          t_TI=^[[>4;2m       t_ZH=^[[3m
  t_da=               t_md=^[[1m          t_Sb=               t_Ts=^[[9m          t_ZR=^[[23m
  t_db=               t_me=^[[m           t_SC=^[]12;         t_ts=^[]2;
--- Terminal keys ---
t_#2 <S-Home>    ^[[1;2H   t_KH <k5>        ^[O*u     t_kb <BS>        ^?
t_#4 <S-Left>    ^[[1;2D   t_KI <k6>        ^[O*v     t_kd <Down>      ^[O*B
t_%1 <Help>      ^[[28;*~  t_KJ <k7>        ^[O*w     t_kh <Home>      ^[[1;*H
t_%i <S-Right>   ^[[1;2C   t_KK <k8>        ^[O*x     t_kl <Left>      ^[O*D
t_&8 <Undo>      ^[[26;*~  t_KL <k9>        ^[O*y     t_kr <Right>     ^[O*C
t_*7 <S-End>     ^[[1;2F   t_PE <PasteEnd>  ^[[201~   t_ku <Up>        ^[O*A
t_@7 <End>       ^[[1;*F   t_PS <PasteStart> ^[[200~       <SgrMouse>  ^[[<*M
t_F1 <F11>       ^[[23;*~  t_k1 <F1>        ^[[11;*~       <Mouse>     ^[[M
t_F2 <F12>       ^[[24;*~  t_k2 <F2>        ^[[12;*~       <xF1>       ^[O*P
t_K1 <kHome>     ^[[1;*~   t_k3 <F3>        ^[[13;*~       <xF2>       ^[O*Q
t_K4 <kEnd>      ^[[4;*~   t_k4 <F4>        ^[[14;*~       <xF3>       ^[O*R
t_K6 <kPlus>     ^[O*k     t_k5 <F5>        ^[[15;*~       <xF4>       ^[O*S
t_K7 <kMinus>    ^[O*m     t_k6 <F6>        ^[[17;*~       <xEnd>      ^[O*F
t_K8 <kDivide>   ^[O*o     t_k7 <F7>        ^[[18;*~       <zEnd>      ^[[8;*~
t_K9 <kMultiply> ^[O*j     t_k8 <F8>        ^[[19;*~       <xHome>     ^[O*H
t_KA <kEnter>    ^[O*M     t_k9 <F9>        ^[[20;*~       <zHome>     ^[[7;*~
t_KB <kPoint>    ^[O*n     t_k; <F10>       ^[[21;*~       <xUp>       ^[[1;*A
t_KC <k0>        ^[O*p     t_kB <S-Tab>     ^[[Z           <xDown>     ^[[1;*B
t_KD <k1>        ^[O*q     t_kD <Del>       ^[[3~          <xLeft>     ^[[1;*D
t_KE <k2>        ^[O*r     t_kI <Insert>    ^[[2;*~        <xRight>    ^[[1;*C
t_KF <k3>        ^[O*s     t_kN <PageDown>  ^[[6;*~        <kDel>      ^[[3;*~
t_KG <k4>        ^[O*t     t_kP <PageUp>    ^[[5;*~
     <SgrMouseRelelase> ^[[<*m

This is the command I use to compile vim.

~ $ sudo ./configure --prefix=/usr/local --with-compiledby=me --with-features=huge --with-x --enable-pythoninterp=dynamic --enable-python3interp=dynamic && sudo make install

--with-x is needed since clipboard support is a must. (I just noticed --with-features=huge implies --with-x.) --enable-pythoninterp=dynamic is not needed, so I'll omit this from now on. --enable-python3interp=dynamic is needed since I have some (not async) functions written in Python3 in .vimrc (they are all written by me and not external plugins).

Here's my .vimrc (with irrelevant or sensitive codes cut).

set t_Co=256
syntax on
set title
set mouse=
set backspace=indent,eol,start
set whichwrap=b,s,h,l,<,>,[,]
set virtualedit=onemore
set number
set display=lastline
set showcmd
set vb t_vb=
set hlsearch
set showmatch
set expandtab
set tabstop=4
set shiftwidth=4
set autoindent
" set cursorline
set history=1000
set winheight=100
set cmdwinheight=10
set equalprg=sort
set conceallevel=2
set concealcursor=nvi
set tags=./tags
set diffopt+=vertical
set nrformats=
set timeoutlen=300
  • 3
    Even if you don't want to do it, it would be pretty helpful to test another terminal emulator. This would allow you to know if the problem comes from your terminal or from Vim itself (which seems unlikely). Also if you use tmux, you could try to reproduce the problem without tmux, maybe it is the culprit.
    – statox
    Oct 9 '19 at 21:08
  • 2
    @statox I think you are totally right. Now I try gnome-terminal which is the base of mate-terminal and still active. (mate-terminal is not abandoned but the last update was 2 years ago.) After the try, I'll append the result to the post. This may takes time because I cannot intentionally reproduce the problem. By the way, I've never used tmux or screen. Anyway, thank you for your advice.
    – ynn
    Oct 10 '19 at 5:24
  • 1
    @ynn Even with gnome-terminal, the problem occurs.
    – ynn
    Oct 13 '19 at 10:49
  • 1
    This doesn't look like graphical glitch, but rather terminal glitch. It happens when multiple unsynchronised threads tried updating the terminal simultaneously. Try removing all your vim plugins and run basic vim with minimal config and put the plugins back one by one, there's likely multiple plugins that race each other when printing something to the screen, or probably you have a bg-ed (background) command running on the shell printing stuff while vim is running.
    – Lie Ryan
    Oct 18 '19 at 3:40
  • 3
    I would rather test with a terminal that has full xterm compatibility, just like well, xterm Oct 22 '19 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.