jankarres / vs-code-copy-file-as-markdown

A Visual Studio Code extension to copy selected files as markdown with filename to the clipboard.
MIT License
1 stars 1 forks source link

Support for Active Editor without File Selection #1

Closed usagizmo closed 1 month ago

usagizmo commented 1 month ago

Thank you for developing this excellent extension. It has been incredibly useful in my workflow.

Are there any plans to make the extension work with the active editor without the need to select a file in the explorer first? Adding support for the active editor would make it more convenient to use while editing code.

For example:


if (!files || files.length === 0) {
    const activeEditor = vscode.window.activeTextEditor;
    if (activeEditor) {
        files = [activeEditor.document.uri];
    } else {
        vscode.window.showInformationMessage('No files or folders selected and no active editor.');
        return;
    }
}
jankarres commented 1 month ago

Thanks for the idea! This could be added as a feature.

Which action (e.g. context menu click or shortcut) would you expect will trigger the copying of the content of the active editor?

usagizmo commented 1 month ago

Thank you for your reply!

It's fine to make it a separate command from extension.copyAsMarkdown, but I would likely set up a shortcut to use it.

Currently, I have set ⇧⌘C for "Copy as markdown with filename", and when I'm editing a file, I use three shortcut keys to copy the code: ⇧⌘E (Explorer) → ⇧F10 (Context Menu) → ⇧⌘C

CleanShot 2024-09-16 at 09 04 07

I imagine this could be done with a single key press in the future.

jankarres commented 1 month ago

I'm happy to let you know, @usagizmo, that I've implemented your feature request. The default keyboard shortcut is alt+cmd+c because I think it's more natural for most users (but you can change it if you want).

If there are any bugs with this feature, feel free to leave feedback in this thread!

usagizmo commented 1 month ago

Thank you for the implementation! It's become even more user-friendly now.