[vim/vim] Regularly exiting vim sets xterm in bracketed paste mode (#1671)

206 views
Skip to first unread message

jombra

unread,
May 1, 2017, 12:14:02 PM5/1/17
to vim/vim, Subscribed

Actually running vim 8.0.586 (bug tested under Xubuntu16.04 and 16.10) I experienced
since more than a week that leaving vim makes the xterm set in bracketed paste mode.
As I am heavily relying on vim I wrote a wrapper script so I don't have to type:
printf "\e[?2004l"
each time I leave vim.
I found that bug "Disable bracketed paste mode for :r !cat?" was closed
10 days ago - maybe this regression may be related to the fix.
I hope my few information can help fixing the bug.
Many thanks for your help!


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

jombra

unread,
May 1, 2017, 12:25:57 PM5/1/17
to vim/vim, Subscribed

Sorry, should have read the bug report 1st - cited bug 1638, as I understand it now,
was closed without doing a fix ... but my reported regression is new - it has to be
introduced less than 4 weeks ago (about two) and there was an update not changing
the situation.
Next time I am more focused to report the bug than finding a workaround ...

Christian Brabandt

unread,
May 1, 2017, 1:42:29 PM5/1/17
to vim/vim, Subscribed

can you bisect the offending commit?

Sylvain303

unread,
May 2, 2017, 2:11:51 AM5/2/17
to vim/vim, Subscribed

Hi,

is it related to my bug?

# clipboard content: /home/sylvain/local/share/applications

# pasting in xfce-terminal OK (shift-ctrl+v) 
# /home/sylvain/local/share/applications
vim8 -u NONE
# just quit, now pasting produces:
#0~/home/sylvain/local/share/applications1~

now 0~ + 1~ surround the clipboard pasted content in the terminal.

Then clipboard content is not altered only the paste behavior in the terminal

vim8 --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May  2 2017 07:59:57)
Included patches: 1-596
Compiled by sylvain@sylvain-nuc
Huge version without GUI.  Features included (+) or not (-):
+acl             +file_in_path    +mouse_sgr       +tag_old_static
+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +float           +mouse_urxvt     -tcl
-balloon_eval    +folding         +mouse_xterm     +termguicolors
-browse          -footer          +multi_byte      +terminfo
++builtin_terms  +fork()          +multi_lang      +termresponse
+byte_offset     +gettext         -mzscheme        +textobjects
+channel         -hangul_input    +netbeans_intg   +timers
+cindent         +iconv           +num64           +title
-clientserver    +insert_expand   +packages        -toolbar
-clipboard       +job             +path_extra      +user_commands
+cmdline_compl   +jumplist        -perl            +vertsplit
+cmdline_hist    +keymap          +persistent_undo +virtualedit
+cmdline_info    +lambda          +postscript      +visual
+comments        +langmap         +printer         +visualextra
+conceal         +libcall         +profile         +viminfo
+cryptv          +linebreak       +python          +vreplace
+cscope          +lispindent      -python3         +wildignore
+cursorbind      +listcmds        +quickfix        +wildmenu
+cursorshape     +localmap        +reltime         +windows
+dialog_con      -lua             +rightleft       +writebackup
+diff            +menu            -ruby            -X11
+digraphs        +mksession       +scrollbind      -xfontset
-dnd             +modify_fname    +signs           -xim
-ebcdic          +mouse           +smartindent     -xpm
+emacs_tags      -mouseshape      +startuptime     -xsmp
+eval            +mouse_dec       +statusline      -xterm_clipboard
+ex_extra        -mouse_gpm       -sun_workshop    -xterm_save
+extra_search    -mouse_jsbterm   +syntax          
+farsi           +mouse_netterm   +tag_binary      
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/home/sylvain/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim8        -lm -ltinfo -lnsl   -ldl    -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions

jombra

unread,
May 2, 2017, 3:50:01 AM5/2/17
to vim/vim, Subscribed

@Sylvain303: Yes, this is quite possible. Looks the same for me - did not spot it.
@chrisbra: Sorry, don't have the time - otherwise my bug report were opened more than one week earlier.

Bram Moolenaar

unread,
May 2, 2017, 5:17:45 AM5/2/17
to vim/vim, Subscribed

> @Sylvain303: Yes, this is quite possible. Looks the same for me - did
> not spot it.
> @chrisbra: Sorry, don't have the time - otherwise my bug report were
> opened more than one week earlier.

The bug says xterm but you mention xfce term. Please keep in mind that
when you set 'term' to xterm but actually use another terminal, things
may go wrong. First try to find out the right setting for 'term',
Vim assumes that if you say "xterm" it really is an xterm.
Terminals simulating an xterm are often not 100% xterm compatible.

--
Sorry, no fortune today.

/// 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 ///

jombra

unread,
May 2, 2017, 5:39:48 AM5/2/17
to vim/vim, Subscribed

@brammool: AFAIK I did not change the configuration, thus Xubuntu seems to default to
TERM=xterm ... but yes, those are xfce4-terminal jobs.
This was never before a problem - so this should be a regression - or current distros may
not work properly if using latest vim (I am currently using a PPA to get vim 8 not part of
Xubuntu 16.10 and 16.04: https://launchpad.net/~jonathonf/+archive/ubuntu/vim).
Is vim more sensitive concerning terminals since the last few weeks?

Sylvain303

unread,
May 3, 2017, 2:43:54 AM5/3/17
to vim/vim, Subscribed

So more info for the reader: http://cirw.in/blog/bracketed-paste
Also some XFCE term info: http://docs.xfce.org/apps/terminal/preferences

xfce-terminal man page says:

       xfce4-terminal emulates the xterm application developed by the X
       Consortium. In turn, the xterm application emulates the DEC VT102
       terminal and also supports the DEC VT220 escape sequences. An escape
       sequence is a series of characters that start with the Esc character.
       xfce4-terminal accepts all of the escape sequences that the VT102 and
       VT220 terminals use for functions such as to position the cursor and to
       clear the screen.

indeed those command fixes the vim8 behavior:

printf "\e[?2004l"

or reset

#1638 :r !cat issue

I currently don't know with value should be OK for $TERM for xfce-terminal + vim8

I tested:
export TERM=xterm - default system no change
export TERM=xterm-256color
export TERM=xterm-color

export TERM=screen - restores paste mode OK

Some vim doc: https://vimhelp.appspot.com/term.txt.html#xterm-bracketed-paste

xubuntu (16.04) packaged vim (7.4) does support $TERM=xterm without letting bracketed-paste mode on when leaving.

to be continued...

Sylvain303

unread,
May 3, 2017, 2:52:20 AM5/3/17
to vim/vim, Subscribed

http://vim.wikia.com/wiki/256_colors_in_vim

says:

XFCE's Terminal uses the same library as the Gnome Terminal to create the virtual terminal, so it actually makes sense to use the same TERM setting for the two terminal emulators. This logic applies in other cases, if an application uses Konsole's or rxvt's code to perform terminal emulation, you can accurately and properly use that application's TERM setting.

export TERM=gnome-256color works too, restoring bracketed-paste off when leaving

antarestrue

unread,
May 3, 2017, 3:57:29 AM5/3/17
to vim/vim, Subscribed

the offending commit seems to be 8.0.569, which is 62cf09b .

cs86661

unread,
May 3, 2017, 10:52:46 AM5/3/17
to vim/vim, Subscribed

Environment: original GNOME terminal 2.32.1 on Ubuntu 11.04

vi -u NONE --noplugin -c :q

The copy/paste function will working abnormally after input above command on GNOME terminal ... (use mouse select any words then paste it.)

cs86661

unread,
May 3, 2017, 11:42:14 AM5/3/17
to vim/vim, Subscribed

Marius Gedminas

unread,
May 4, 2017, 5:12:36 AM5/4/17
to vim/vim, Subscribed

Environment: original GNOME terminal 2.32.1 on Ubuntu 11.04

That is six years old and doesn't get security updates! Do consider upgrading.

FWIW gnome-terminal 3.20.2 (and, more importantly, libvte 2.91) from Ubuntu 17.04 do not suffer from this problem.

Tony Lechner

unread,
May 4, 2017, 1:45:41 PM5/4/17
to vim/vim, Subscribed

I'm not sure this is entirely vim's fault.

The issue is moreso that many terminals try to support bracketed paste, but don't actually do so properly.

See: https://bugs.launchpad.net/ubuntu/+source/vte/+bug/1350334/comments/6

Since there's no practical way to detect if the terminal emulator properly implements it, I don't see a way to fix that doesn't involve a regression of what 62cf09b was fixing in the first place.

.vimrc workaround

I plopped this in my .vimrc on affected machines (my debian stable/jessie box running terminator). Just has vim issue a "turn off bracketed paste" on launch.

" workaround for https://github.com/vim/vim/issues/1start671
if has("unix")
  let s:uname = system("echo -n \"$(uname)\"")
  if !v:shell_error && s:uname == "Linux"
    set t_BE=
  endif
endif

This works for me personally.

Ramel Eshed

unread,
Jun 6, 2017, 1:24:35 PM6/6/17
to vim_dev, v...@noreply.github.com, subsc...@noreply.github.com, reply+00b1d1981b71fb2f9de59052076cd1b0fed4ba6...@reply.github.com, vim-dev...@256bit.org
Hi All,

Any updates about this issue?
I'm using gnome terminal 2.31.3 (which comes with RHEL6) and must set t_BE= to avoid the corrupted pate issue in the terminal after exiting Vim.

I think that there is no reason to break old behavior, even if there is a workaround for that.

Thanks,
Ramel

vim-dev ML

unread,
Jun 6, 2017, 1:25:07 PM6/6/17
to vim/vim, vim-dev ML, Your activity

Christian Brabandt

unread,
Jun 6, 2017, 4:04:38 PM6/6/17
to vim/vim, vim-dev ML, Comment

It is not even clear, that this is a vim bug and not a terminal bug. Perhaps consider using a different terminal that supports bracketed-paste mode correctly.


You are receiving this because you commented.

Bram Moolenaar

unread,
Jun 6, 2017, 4:58:50 PM6/6/17
to vim...@googlegroups.com, Ramel Eshed, v...@noreply.github.com, subsc...@noreply.github.com, reply+00b1d1981b71fb2f9de59052076cd1b0fed4ba6...@reply.github.com, vim-dev...@256bit.org
The support for bracketed paste was added for good reasons. That before
this many terminals that aren't actually an xterm worked fine, even when
$TERM is set to xterm, doesn't mean this will keep working forever.
The basic problem is that if a terminal isn't really an xterm, then it
can break at any time. That isn't Vim's fault. We will try to make it
work even when the user did not setup his system exactly right, but in
this case I don't see how we can detect a "bad terminal". I wish every
terminal had a way to tell us its features instead of relying on setting
$TERM correctly.

There should also be a way to separate a term response from what the
user typed. Haven't seen any progress on that, unfortunately.

--
hundred-and-one symptoms of being an internet addict:
17. You turn on your intercom when leaving the room so you can hear if new
e-mail arrives.

vim-dev ML

unread,
Jun 6, 2017, 4:59:14 PM6/6/17
to vim/vim, vim-dev ML, Your activity

antarestrue

unread,
Jun 7, 2017, 12:01:38 AM6/7/17
to vim/vim, vim-dev ML, Comment

Is it possible to save the bracket mode state when entering vim, and then restore it back when leaving?


You are receiving this because you commented.

Ramel Eshed

unread,
Jun 7, 2017, 11:40:50 AM6/7/17
to vim_dev, ram...@gmail.com, v...@noreply.github.com, subsc...@noreply.github.com, reply+00b1d1981b71fb2f9de59052076cd1b0fed4ba6...@reply.github.com, vim-dev...@256bit.org
On Tuesday, June 6, 2017 at 11:58:50 PM UTC+3, Bram Moolenaar wrote:
> Ramel Eshed wrote:
>
> > Any updates about this issue?
> > I'm using gnome terminal 2.31.3 (which comes with RHEL6) and must set t_BE= to avoid the corrupted pate issue in the terminal after exiting Vim.
> >
> > I think that there is no reason to break old behavior, even if there is a workaround for that.
>
> The support for bracketed paste was added for good reasons. That before
> this many terminals that aren't actually an xterm worked fine, even when
> $TERM is set to xterm, doesn't mean this will keep working forever.
> The basic problem is that if a terminal isn't really an xterm, then it
> can break at any time. That isn't Vim's fault. We will try to make it
> work even when the user did not setup his system exactly right, but in
> this case I don't see how we can detect a "bad terminal". I wish every
> terminal had a way to tell us its features instead of relying on setting
> $TERM correctly.
>
> There should also be a way to separate a term response from what the
> user typed. Haven't seen any progress on that, unfortunately.
>

OK, I understand. Thank you for this explanation.

vim-dev ML

unread,
Jun 7, 2017, 11:41:30 AM6/7/17
to vim/vim, vim-dev ML, Your activity

Bram Moolenaar

unread,
Jun 7, 2017, 4:25:37 PM6/7/17
to vim/vim, vim-dev ML, Comment

> Is it possible to save the bracket mode state when entering vim, and
> then restore it back when leaving?

There is no way to request the current state for bracketed paste mode.
Vim always switches it off when exiting.



--
hundred-and-one symptoms of being an internet addict:
23. You can't call your mother...she doesn't have a modem.


/// 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 ///


You are receiving this because you commented.

Christian Brabandt

unread,
Aug 2, 2017, 4:03:21 PM8/2/17
to vim/vim, vim-dev ML, Comment

Closed #1671.


You are receiving this because you commented.

Reply all
Reply to author
Forward
0 new messages