2

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!

Philippe Hebert
  • 1,616
  • 2
  • 24
  • 51
  • 1
    use the folding arrows in the left-gutter, when function collapsed select that line, 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 – rioV8 Sep 18 '21 at 00:54
  • Nice! That works! Want to post that as an answer so that I can upvote and mark resolved? :) – Philippe Hebert Sep 20 '21 at 14:03

1 Answers1

6

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.

rioV8
  • 24,506
  • 3
  • 32
  • 49
  • Be sure to select the WHOLE collapsed line. You must select to the beginning of the next line below the collapsed lines. I didn't think collapsed select thing worked at first, till I realized the issue. Simply double clicking to select the visible portion of the collapsed lines doesn't seem to be enough. – Chris Nadovich Jan 21 '23 at 00:30