visual-studio-codekeyboard-shortcutscode-navigation

VSCode: Select entire function definition?


Is there a way to select an entire function definition in VSCode? That's a recurring action in my dev workflow, and I'd like to automate it instead of using my mouse. Couldn't find a shortcut for it. Surely there ought to be a way?

I'm using python/javascript as my languages, with Python (ms-python.python) & JavaScript and TypeScript Nightly (ms-vscode.vscode-typescript-next) extensions installed.

Thank you! 🙏


Solution

  • Use the folding arrows in the left-gutter.

    When function collapsed select that line and Copy

    It depends on the language what a function is and how to separate them, you need to build an AST from the text and the language server does this to determine the fold arrows.