Add Pasted Code Segment File and Line Numbers In Prompt Message

Feature request for product/service

Cursor IDE

Describe the request

When pasting code into chat, add the literal filename and line numbers in the prompt message where the code was pasted so the prompt can specifically refer to them, instead of the current functionality where pasted code is just added to the context of the entire prompt with no effect of where it was pasted in the prompt message.
By having the filename and line numbers as literal text in the request, it allows giving specific instructions related to each code pasted. Right now it seems to just add the code to the context, and the model does not know how each pasted code segment relates to the message body of the request.
I have to manually type out of the file and line numbers when referring to code segments in context sometimes, which seems a bit redundant.
This already similarly works when you drag an open file/tab into the chat, where it places the file in the chat right at the end, where you are usually typing. This would also make it easy to paste multiple segments of code and in chat form a request tying them all together.

Default Copy/Paste Behavior
This is how it looks now if you paste code segments while typing out a prompt.
If it’s just one pasted code segment in a new chat, this usually causes no issues. But if its multiple or in a chat with lots of historical context, the model can misunderstand how the pasted code relates to the prompt, especially with multiple segments pasted.

Current Workaround
Manually type out the lines of the pasted code segments.

Feature Requested Solution
Pasting the code segments automatically adds the filename and line numbers in the message where your cursor was.


or could show only the file in the context area to reduce clutter

Related Threads:

Operating System (if it applies)

Windows 10/11

1 Like