Escape sequences printed to the console when starting Gvim 8.1

40 views
Skip to first unread message

Philip Pemberton

unread,
Jan 6, 2021, 11:14:22 AM1/6/21
to vim_dev
I recently installed Syntastic (https://github.com/vim-syntastic/syntastic/) under Vim 8.1 (from https://launchpad.net/~jonathonf/+archive/ubuntu/vim ) on Ubuntu 18.04, and have stumbled upon an odd issue.

If I start gvim (vim-gtk3) from a terminal, I see a sequence of escape characters printed before Vim starts up:

$ gvim
�[>4;m�[>4;2m

This also happens with the standard 'vim' (it's worst if I'm SSH-ing into the machine), right after Vim starts. This ends up corrupting the screen and means I have to force a screen refresh to get Vim to work correctly again.

I've tested a few different versions of Vim on a few OSes:

- Ubuntu 18.04 with Vim 8.0 from the Ubuntu repos -- works fine
- Ubuntu 18.04 with your Vim 8.1 -- has the issue
- Ubuntu 20.04 with either Ubuntu's Vim 8.1 or Jonathon's Vim 8.2 -- works fine

Disabling Syntastic fixes the issue, though I'd rather not do this as I've come to rely on it.

I've reported this to the Syntastic developers, and they suggested that while Syntastic may be triggering this bug, it's not responsible for it -- and that I should report the bug here:

Does anyone know of a bug resembling this in 8.1, or know of a workaround?

Thanks
Phil.

Tony Mechelynck

unread,
Jan 6, 2021, 3:54:01 PM1/6/21
to vim_dev
Works for me with Bram's Vim 8.2.2305 (Big with GTK3) with or without
--clean in both konsole and xterm

ISTR that a similar bug happened in the past and was fixed.

Best regards,
Tony.

Tony Mechelynck

unread,
Jan 6, 2021, 4:03:10 PM1/6/21
to vim_dev
Oops - I don't have Syntastic; but have you tried a more recent
version? The latest version as of this writing is 8.2.2306 and the
8.2.0 release happened on 12 December 2019, more than a year ago.

Best regards,
Tony.

John Little

unread,
Jan 6, 2021, 4:55:25 PM1/6/21
to vim_dev
- Ubuntu 18.04 with your Vim 8.1 -- has the issue

I wonder why you need Vim 8.1.  At  https://launchpad.net/~jonathonf/+archive/ubuntu/vim I see only vim 8.2 for 18.04. 

Regards, John Little

Philip Pemberton

unread,
Jan 6, 2021, 7:56:41 PM1/6/21
to vim_dev
I've just solved a packaging issue on the machine, and Apt has pulled down Vim 8.2.1897, with the same issue. Console output below:

philpem@cheetah:~$ gvim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Oct 24 2020 16:26:37)
Included patches: 1-1897
Modified by jonathon....@york.ac.uk
Compiled by jonathon....@york.ac.uk
Huge version with GTK3 GUI. Features included (+) or not (-):
+acl -farsi +mouse_sgr +tag_binary
+arabic +file_in_path -mouse_sysmouse -tag_old_static
+autocmd +find_in_path +mouse_urxvt -tag_any_white
+autochdir +float +mouse_xterm +tcl
-autoservername +folding +multi_byte +termguicolors
+balloon_eval -footer +multi_lang +terminal
+balloon_eval_term +fork() -mzscheme +terminfo
+browse +gettext +netbeans_intg +termresponse
++builtin_terms -hangul_input +num64 +textobjects
+byte_offset +iconv +packages +textprop
+channel +insert_expand +path_extra +timers
+cindent +ipv6 +perl +title
+clientserver +job +persistent_undo +toolbar
+clipboard +jumplist +popupwin +user_commands
+cmdline_compl +keymap +postscript +vartabs
+cmdline_hist +lambda +printer +vertsplit
+cmdline_info +langmap +profile +virtualedit
+comments +libcall -python +visual
+conceal +linebreak +python3 +visualextra
+cryptv +lispindent +quickfix +viminfo
+cscope +listcmds +reltime +vreplace
+cursorbind +localmap +rightleft +wildignore
+cursorshape +lua +ruby +wildmenu
+dialog_con_gui +menu +scrollbind +windows
+diff +mksession +signs +writebackup
+digraphs +modify_fname +smartindent +X11
+dnd +mouse +sound -xfontset
-ebcdic +mouseshape +spell +xim
+emacs_tags +mouse_dec +startuptime +xpm
+eval +mouse_gpm +statusline +xsmp_interact
+ex_extra -mouse_jsbterm -sun_workshop +xterm_clipboard
+extra_search +mouse_netterm +syntax -xterm_save
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/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wdate-time -g -O2 -fdebug-prefix-map=/build/vim-KZNIhZ/vim-8.2.1897=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lselinux -lcanberra -lacl -lattr -lgpm -ldl -L/usr/lib -llua5.2 -Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-2.5 -lpthread -lgmp -ldl -lcrypt -lm

philpem@cheetah:~$ gvim
[>4;m [>4;2mphilpem@cheetah:~$ gvim
[>4;m [>4;2mphilpem@cheetah:~$

Thanks
Phil.

Christian Brabandt

unread,
Jan 7, 2021, 4:51:24 AM1/7/21
to vim_dev

On Mi, 06 Jan 2021, Philip Pemberton wrote:

> I've just solved a packaging issue on the machine, and Apt has pulled down Vim 8.2.1897, with the same issue. Console output below:
> philpem@cheetah:~$ gvim
> [>4;m [>4;2mphilpem@cheetah:~$ gvim
> [>4;m [>4;2mphilpem@cheetah:~$

Looks a bit like the terminal version query. What terminal are you
using? It only happens with syntastic installed? So with gvim --clean
this doesn't show up?


Best,
Christian
--
Ich habe das Problem, daß ich zuviel weiß.
-- Prof. Informationssysteme, FH Schweinfurt

Bram Moolenaar

unread,
Jan 7, 2021, 8:14:39 AM1/7/21
to vim...@googlegroups.com, Philip Pemberton

Philip Pemberton wrote:

> I've just solved a packaging issue on the machine, and Apt has pulled down
> Vim 8.2.1897, with the same issue. Console output below:
>
[...]

> philpem@cheetah:~$ gvim
> [>4;m [>4;2mphilpem@cheetah:~$ gvim
> [>4;m [>4;2mphilpem@cheetah:~$

You probably have a shell command in your startup files.
Combined with a terminal that doesn't ignore this escape sequence
(iterm?).

--
hundred-and-one symptoms of being an internet addict:
96. On Super Bowl Sunday, you followed the score by going to the
Yahoo main page instead of turning on the TV.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Dominique Pellé

unread,
Jan 7, 2021, 10:14:30 AM1/7/21
to vim_dev
Bram Moolenaar <Br...@moolenaar.net> wrote:

> Philip Pemberton wrote:
>
> > I've just solved a packaging issue on the machine, and Apt has pulled down
> > Vim 8.2.1897, with the same issue. Console output below:
> >
> [...]
>
> > philpem@cheetah:~$ gvim
> > [>4;m [>4;2mphilpem@cheetah:~$ gvim
> > [>4;m [>4;2mphilpem@cheetah:~$
>
> You probably have a shell command in your startup files.
> Combined with a terminal that doesn't ignore this escape sequence
> (iterm?).

The escape codes in the shell prompt has nothing to do
with Vim, unless it's a shell started in vim with :terminal ?

I recall that for recent vim, terminals such as xfce4-terminal
and gnome-terminal (maybe others) in Ubuntu-18.04 are too
old and Vim can output spurious codes on the terminal,
It hapens for example when doing :!date
Ubuntu-20.04 does not have this issue (newer terminals).
There is a workaround: for old terminals: add the following
lines at the beginning of your ~/.vimrc:

" Work around spurious characters in old terminals when doing :!date
set t_TE= t_TI=

Regards
Dominique

Bram Moolenaar

unread,
Jan 7, 2021, 11:59:18 AM1/7/21
to vim...@googlegroups.com, Dominique Pellé

Dominique wrote:

> Bram Moolenaar <Br...@moolenaar.net> wrote:
>
> > Philip Pemberton wrote:
> >
> > > I've just solved a packaging issue on the machine, and Apt has pulled down
> > > Vim 8.2.1897, with the same issue. Console output below:
> > >
> > [...]
> >
> > > philpem@cheetah:~$ gvim
> > > [>4;m [>4;2mphilpem@cheetah:~$ gvim
> > > [>4;m [>4;2mphilpem@cheetah:~$
> >
> > You probably have a shell command in your startup files.
> > Combined with a terminal that doesn't ignore this escape sequence
> > (iterm?).
>
> The escape codes in the shell prompt has nothing to do
> with Vim, unless it's a shell started in vim with :terminal ?

It's not the shell prompt but the codes that Vim uses to change the
terminal state. A shell command needs a different state than what Vim
uses when editing.

> I recall that for recent vim, terminals such as xfce4-terminal
> and gnome-terminal (maybe others) in Ubuntu-18.04 are too
> old and Vim can output spurious codes on the terminal,
> It hapens for example when doing :!date
> Ubuntu-20.04 does not have this issue (newer terminals).
> There is a workaround: for old terminals: add the following
> lines at the beginning of your ~/.vimrc:
>
> " Work around spurious characters in old terminals when doing :!date
> set t_TE= t_TI=

I would not call them "old terminals", but newish terminals with bugs.
Old terminals just ignore codes that are not recognized. These newish
terminals had bugs that got fixed at some point, so perhaps you call the
version with a bug old?

Anyway, patch 8.2.2307 attempts to fix the problem for when a shell
command is used before Vim has started up. I hope there are no side
effects, we'll have to see.

--
hundred-and-one symptoms of being an internet addict:
101. U can read htis w/o ny porblm and cant figur eout Y its evn listd.

Philip Pemberton

unread,
Jan 7, 2021, 7:25:50 PM1/7/21
to vim_dev
On Thursday, 7 January 2021 at 16:59:18 UTC Bram Moolenaar wrote:

Dominique wrote:

> I recall that for recent vim, terminals such as xfce4-terminal
> and gnome-terminal (maybe others) in Ubuntu-18.04 are too
> old and Vim can output spurious codes on the terminal,
> It hapens for example when doing :!date
> Ubuntu-20.04 does not have this issue (newer terminals).
> There is a workaround: for old terminals: add the following
> lines at the beginning of your ~/.vimrc:
>
> " Work around spurious characters in old terminals when doing :!date
> set t_TE= t_TI=

I would not call them "old terminals", but newish terminals with bugs.
Old terminals just ignore codes that are not recognized. These newish
terminals had bugs that got fixed at some point, so perhaps you call the
version with a bug old?

You're right in that I'm using an XFCE environment -- with xfce4-terminal 0.8.7.4. It's annoying to hear that gnome-terminal has the same bug, that was the next thing I was going to try!
Xterm also seems to have the issue, but not as repeatably as xfce4-terminal.

I updated to Jonathon's latest Vim 8.2 package from the PPA -- according to :version, this is "Included patches: 1-2306".

After five tries opening a small Python file with Vim + syntastic (and Dominique's workaround in my vimrc), it displayed this stream of garbage on the top line:

^[P1$r2 q^[\^[[?12;2$y

In xfce4-terminal it's much worse:

^[[2;2R^[[3;6R^[[>1;5202;0c^[]10;rgb:ffff/ffff/ffff^G^[]11;rgb:0000/0000/0000^G

Shelling out to an external application seems to be the smoking gun - Syntastic starts up a Python linter when a file is opened or saved.

I had no issues with gvim.

Here's the small Python file I used:

addr = 0x10d8
while (addr & 0xFF00) != 0x0C00:
    print(hex(addr))
    addr -= 4

 
Anyway, patch 8.2.2307 attempts to fix the problem for when a shell
command is used before Vim has started up. I hope there are no side
effects, we'll have to see.

I'll see if I can pull down a later version of Vim with the 2307 patch, and build from source (perhaps with a few fewer addons!). Hopefully I can at least report back as to whether the bug is fixed.
Otherwise it seems like I'll be looking for a less buggy terminal emulator...

Thanks
Phil.
 

John Little

unread,
Jan 7, 2021, 8:14:02 PM1/7/21
to vim_dev
I installed Ubuntu 18.04 and reproduced the problem.  Until seeing your post, I thought it was a gnome-terminal problem, because it does not occur for me with xterm, though I didn't try hard.  xterm tends to be the least buggy emulator IME, perhaps because it has a rigorous test environment.

A workaround is to start the gui early, by putting a "gui" command in .vimrc.  Back in 2018 there were a few folks using similar workarounds.

Regards, John Little


John Little

unread,
Jan 7, 2021, 8:32:06 PM1/7/21
to vim_dev
After reading here, I went back to the 18.04 install, and updated vim to the latest, and the problem does not occur now.

Regards, John Little

Reply all
Reply to author
Forward
0 new messages