Use IPython REPL in VS Code

前端 未结 6 1386
天涯浪人
天涯浪人 2020-12-29 04:15

Using the Python extension of Visual Studio Code, I can select some code, right-click it, and select \"Run Selection/Line in Python Terminal\" (alternatively, I can hit Shif

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-29 05:02

    Use "IPython for VSCode" plugin.

    Install it and then use Send Select Text (or current line) To IPython

    If you want use shortcut setting with original shift+enter to execute command above, Use One of below methods.

    Shortcut setting - Normal

    1. open shortcut setting: Macos it's cmd+k cmd+s.

    2. search command above and right click to modify the keyboard binding as shift+enter.

    3. Next, right click again to modify the When expression as:

    editorTextFocus && !findInputFocussed && !python.datascience.ownsSelection && !replaceInputFocussed && editorLangId == 'python'
    
    1. Right click and select show same key bindings

    2. Find command Python: Run Selection/Line in Python Terminal and Right click to disable it.

    Shortcut setting - JSON

    1. Open shortcut setting and click Upper right corner to open JSON config

    2. Append these settings:

        {
            "key": "shift+enter",
            "command": "ipython.sendSelectedToIPython",
            "when": "editorTextFocus && !findInputFocussed && !python.datascience.ownsSelection && !replaceInputFocussed && editorLangId == 'python'"
        },
        {
            "key": "shift+enter",
            "command": "-python.execSelectionInTerminal",
            "when": "editorTextFocus && !findInputFocussed && !python.datascience.ownsSelection && !replaceInputFocussed && editorLangId == 'python'"
        }
    

提交回复
热议问题