Any way to paste code as text, instead of adding at the top as a part of file?

Let’s say I need to add a small piece of code from a file, but when I paste it in the chat, it pastes it as a read-only block with the file name attached at the top. So I cannot edit it, and I cannot explain to the AI which block of code I want to edit, because it all gets pasted at the top, instead of under my explanation paragraphs.

1 Like

Hello, could I please receive an answer?
This causes problems with explaining the AI what to do, as the code is pasted out of context.

same question , paste as a file ai does not pick up and solve the problem,very annoying

Hi @fun_strange and @xzkeee ,

I experience the same behaviour and the devs are aware of the dynamic.

It seems to happen only when the code being pasted in the prompt area is over a particular size.

Here’s a screenshot I have taken previously:

Hopefully it will be resolved in a future release.

I am sure the current behaviour has some reason for existing, but it does make it a bit inconvenient when you want to paste in some code at a particular place in your prompt, and then it gets hoicked up to the context area.

3 Likes

I’m experiencing the same issue. litecode explained it very clearly. Please fix because it’s very annoying to not be able to paste as normal text.

1 Like

Agree.
A temporary solution I found is to keep some text file always open where I would first write the message for the AI and then copy it into the chat or attach that file as context.

1 Like

Thank you! This temporary solution works, but still Cursor team, please fix this issue. One of the main benefits of Cursor is to avoid copying and pasting.

1 Like

I have the same issue.

What is the solution to this?

I like to have the option to paste the code into the chat prompt and not above in the context area.

The only reliable solution I found is to keep another editor (like VSCode) open, write out the whole prompt in it (where you can paste anything as text), then copy that from there to Cursor’s chat.

How can I reproduce this? I tried pasting 1488 lines, and it worked fine. Should I try more lines?

Does it paste as plaintext for you? Or attaches as part of the context at the top?

Plaintext within the prompt I am typing.

Did you copy from an external source? If i copy from a file that is open inside Cursor (specifically a part of the workspace repo especially) it will always paste that at the top instead of as plaintext

I copied from an open file in the same Cursor instance. Granted, everything was freshly opened. Not sure if this becomes corrupted after some usage.

I’ve noticed it may reproduce randomly. I think it doesn’t depend on the number of lines, as long as it’s more than 1 line. However, it seems to reproduce with certain files, but not with others. It probably also doesn’t depend on the file’s extension. E.g. I had two html files open and copying from one pastes as plaintext, but copying from the other one attaches as context at the top

Actually I think it doesn’t reproduce when you copy and paste too many lines. It always reproduces for me when I copy a smaller number of lines, for example 5.

So the steps to reproduce are:

  1. Have Cursor open with some large file (100 lines for example). Preferably a file from the currently open folder/repo/workspace.
  2. Copy any 5 lines from that file.
  3. Paste into the chat.

It attaches as ‘context’ at the top instead of as plaintext