When I try to paste a long text/code in any editor in Terminal or Iterm2, only part of the text is pasted.

For example, as you can see below, I just generated a wall of text with 3000 words and copied it. When I try to paste the text, the editor stucks. I can't even use arrow keys. it starts write characters like ^[OA, ^[OB etc.

I can't even escape insert mode with the esc key. Only Ctrl + C works.

enter image description here

I tried to set the slow paste setting on Iterm2 but nothing changed.

Any help appreciated.


1 Answer 1


One possible way to paste a long line of text into a Terminal window would be to use a "Here" document. I tested this by using the following steps.

  1. I created a single line in TextEdit containing the sentence "Now is the time for all good men to come to the aid of their country." repeated 195 times. This plain text document is 13650 characters in size and contains 3120 words. The final character in the document is a newline.

  2. I opened a new Terminal window and entering the command below.

    cat <<"EOF" >test.doc
  3. I copy and pasted the entire document from the TextEdit application to the Terminal window.

  4. The following line was entered to indicate the end of document.

  5. The characters saved in the file test.doc where inserted in a document be edited by nano.

  • Hi @David, thanks for the answer. But pasting process stucks on the same word as in vi editor.
    – Ziya
    Sep 2, 2022 at 6:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .