26

What command do I have to use in VSCode to toggle the docstring?

I have searched in settings for docstring, help but nothing that makes sense shows up.

user3139545
  • 6,882
  • 13
  • 44
  • 87

3 Answers3

16

I guess you want parameter suggestions for a method or function. Shortcut for mac is: cmd + Shift + Space.

See other question: Is there a "quick documentation" shortcut for VS code?

For all shortcuts press: cmd + k, cmd + r.

Johnny M
  • 359
  • 2
  • 7
14

You can hit Ctrl + K Ctrl + I. This will execute the editor.action.showHover command and will display the same text that is displayed when you hover over for example a function. Unfortunately there seems to be no corresponding editor.action.hideHover command (I searched the keybindings.json). But it should be possible to hide the text again by pressing the Esc key.

HaaLeo
  • 10,065
  • 3
  • 44
  • 55
  • 1
    mac: cmd + K, cmd + I – samaspin Jan 16 '19 at 12:29
  • 5
    This does not do anything. – Soerendip Aug 13 '19 at 23:11
  • The marker needs to be before the paranthesis when calling the above command. If | is the position of the marker, "a b c d".split(|) will not show a docstring, but "a b c d".split|() will. – TomNorway Dec 11 '19 at 13:13
  • @TomNorway and this is unfortunate! the `cmd + k cmd + I` docstring is color-formatted, but not callable from ( | ). `cmd + shift + space` is callable from ( | ), but not colorformatted. sigh – Bananeen May 15 '23 at 00:48
  • What do you mean by color-formatted? I can reproduce what you're saying about `|`, I get docstrings with color in them in both cases. Edit: Ah, I see a difference for e.g. `np.array()`. – TomNorway May 15 '23 at 11:18
-4

You can either install an extension/snippet to provide it (Python only right now) https://marketplace.visualstudio.com/items?itemName=njpwerner.autodocstring

Or you can create a user-defined snippet and assign it to a hotkey.

Matt Sephton
  • 3,711
  • 4
  • 35
  • 46
  • No what im after. When you hover over a function in java python etc you get a textbox showing that functions docstring. I would like to toggle this text using the keyboard insted of hover since im using vim mode. – user3139545 Mar 28 '18 at 18:10
  • 2
    What you're now describing is not a docstring. But maybe you want the hotkey `Control+Space`? – Matt Sephton Mar 28 '18 at 18:43