Retrieve Selected Text Directly from IDE

Resolved 💬 6 comments Opened Dec 17, 2025 by youaodu Closed Dec 17, 2025
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What feature would you like to see?

I need a feature that can retrieve the selected text directly from the IDE. Currently, I have to manually specify the file and line numbers like @xxxx.file Line:n Line:m, which is quite cumbersome.

Additional information

_No response_

View original on GitHub ↗

6 Comments

etraut-openai contributor · 8 months ago

The extension exposes a command called "chatgpt.addToThread". It doesn't have a key binding by default, but you can add one. Just go to the gear icon in the upper right and select "keyboard shortcuts". Then select "Add to Codex Thread" and define a keybinding of your choice (I prefer cmd+L). Then select the lines you want to include in your context and choose the key binding. You can also select the command from the command palette, but that's kind of cumbersome.

gpeal contributor · 8 months ago

@etraut-openai is correct here. It's very handy to bind this to a keyboard shortcut as well.

<img width="1188" height="300" alt="Image" src="https://github.com/user-attachments/assets/2994a6f1-5dfa-415a-a5c0-2fc52dda5b9d" />

youaodu · 8 months ago

Thank your reply.
I've noticed that the "Add to Codex Thread" feature is designed for the plugin's page interface.
This is an excellent feature that I find extremely useful.

<img width="1853" height="680" alt="Image" src="https://github.com/user-attachments/assets/631771d0-65b2-4b30-af0b-7183f57136ac" />

Can this input box support retrieving selected text? I'm not very accustomed to using the interactive interface.

The extension exposes a command called "chatgpt.addToThread". It doesn't have a key binding by default, but you can add one. Just go to the gear icon in the upper right and select "keyboard shortcuts". Then select "Add to Codex Thread" and define a keybinding of your choice (I prefer cmd+L). Then select the lines you want to include in your context and choose the key binding. You can also select the command from the command palette, but that's kind of cumbersome.
gpeal contributor · 8 months ago

At the moment, you will need to use the extension to use this. There is also an "Auto context" butto in the composer in the extension which will automatically include things like your current selection so you can simply refer to whatever is currently selected without manually adding it. We may add this to the CLI at some point but have nothing to announce at the moment.

youaodu · 8 months ago

Thanks.
Is there open source plan for the plugin?

etraut-openai contributor · 8 months ago

We don't have any plans to open source the VS Code extension. However, the extension is built upon the CLI, which is open-sourced.