OS X copy paste into Terminal adds fdbf bfb9 b083 to beginning and end of selection

5

1

For the life of me, I can't figure this out.

When using a browser (doesnt matter which), if I select text, then paste in Vim or Neovim or Nano, I see characters added to the beginning and end of my selection.

For example, I select "answer" from this page, then paste it over in Terminal I get:

??????answer??????

Saving this pasted data to file with .bin extension and then opening in Vim with this auto command helper:

augroup Binary
   au!
   au BufReadPre  *.bin let &bin=1
   au BufReadPost *.bin if &bin | %!xxd
   au BufReadPost *.bin set ft=xxd | endif
   au BufWritePre *.bin if &bin | %!xxd -r
   au BufWritePre *.bin endif
   au BufWritePost *.bin if &bin | %!xxd
   au BufWritePost *.bin set nomod | endif
augroup END

I get this output:

0000000: fdbf bfb9 b083 616e 7377 6572 fdbf bfb9  ......answer....
0000010: b083 0a                                  ...

So, you can see that I get

fdbf bfb9 b083

added to the beginning, and I get

fdbf bfb9 b083

added to the end.

Any ideas on what this is about?

The only recent major change I can remember is upgrading OS X to Yosemite, so sure that's potentially a large update.

EDIT: I suspect Terminal is the source of the issue. I've been able to use iTerm2 without this problem.

mrk

Posted 2016-02-25T15:54:24.907

Reputation: 111

Not exactly sure what you are copying, but could they be Unicode curly quotes? – baum – 2016-02-25T19:35:45.113

@baum, I explicitly mentioned an example of what I am copying "For example, I select 'answer' from this page, then paste it over in Terminal I get"... – mrk – 2016-02-26T15:05:23.177

two questions - what do you get when you paste in it in TextEdit, and what Terminal settings are you using (actually: "profile" settings in Terminal.app's preferences) – Florenz Kley – 2016-03-01T17:27:19.373

@FlorenzKley not sure TextEdit is a viable option here, it forces me to save in RTF or ODT or other formats which add all kinds of extra c**p into the file :) But did it anyways and opening the file with vim or hex editor, I don't get the fdbf stuff in it. I have narrowed down the issue to Terminal. – mrk – 2016-03-01T18:46:18.087

@FlorenzKley without dumping my entire Terminal preferences, some notable settings are (untouched by me aka The Defaults)...terminfo = xterm-256color, text-encoding = Unicode (UTF-8) – mrk – 2016-03-01T18:48:59.430

wrt to TextEdit: to switch between formats, I use the menu Format -> Make Rich Text or Format -> Make Plain Text, depending on what format the open window is currently in. Adds nothing to it. wrt to Terminal.app: I asked because I had some ideas about the character encoding. But I can't replicate anything, neither on Mavericks, nor Yosemite, nor El Cap. Can you copy something (like "answer" above) and then in Terminal and iTerm do a "pbpaste | od -x" please? For me the result is "0000000 6e61 7773 7265", which spells out to just "answer"... – Florenz Kley – 2016-03-02T12:04:17.497

@FlorenzKley Hmm, ok, I copy that text and in Terminal do pbpaste|od -x and get almost what u get..... pbpaste|od -x 0000000 6e61 7773 7265 0000006. Using MacVim with no vimrc ( vim -u NONE), using nano, using Neovim, using default OS X vim install, pasting in still gives me the FDBF stuff....so by including Nano, I'm trying to rule out a stock-vim/vim/neovim as the issue. The pbpaste into iTerm and Terminal is the same, yet the paste (cmd-V) into vi, vim, nano, neovim is messed up.... – mrk – 2016-03-02T19:46:36.657

I'm going to cross post this to apple.stackexchange.com, just now found that site. – mrk – 2016-03-02T19:48:33.173

Answers

3

This error has to do with a feature known as bracketed pasted mode[1]. Neovim does not support it yet[2]. You get the error above if an application acts like it can support that mode, but fails to support it.

In neovim open a terminal window. With 'always' in the clipboard, run the following:

pbpaste | xxd

There should be no errors. Now run the following:

cat | xxd

Enter ⌘-v followed by Ctrl-D.

You should expect to see the errors. In the second case, input is being handled by the application, which wraps the input with special bytes. The padded bytes are sent as stdin.

[1] https://cirw.in/blog/bracketed-paste

[2] https://github.com/neovim/neovim/issues/3476.

cdosborn

Posted 2016-02-25T15:54:24.907

Reputation: 532

1niiice! And around so long. Learn something new every day :-) – Florenz Kley – 2016-03-09T03:32:22.120