Skip to content

Commit 03ef0e5

Browse files
authored
Merge pull request #7605 from microsoft/python-smart-send
Updating Python Run options to reference Smart Send
2 parents a2ac660 + 728fb10 commit 03ef0e5

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

docs/languages/python.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ To experience Python, create a file (using the [File Explorer](/docs/getstarted/
3535
print("Hello World")
3636
```
3737

38-
The Python extension then provides shortcuts to run Python code using the currently selected interpreter (**Python: Select Interpreter** in the Command Palette). To run the active Python file, click the **Run Python File in Terminal** play button in the top-right side of the editor.
38+
The Python extension then provides shortcuts to run Python code using the currently selected interpreter (**Python: Select Interpreter** in the Command Palette). To run the active Python file, click the **Run Python File** play button in the top-right side of the editor.
3939

4040
![Using the run python file in terminal button](images/python/run-python-file-in-terminal-button.png)
4141

42-
You can also run individual lines or a selection of code with the **Python: Run Selection/Line in Python Terminal** command (`kbstyle(Shift+Enter)`). If there isn't a selection, the line with your cursor will be run in the Python Terminal. An identical **Run Selection/Line in Python Terminal** command is available on the context menu for a selection in the editor. The same terminal will be used every time you run a selection or a line in the terminal/REPL, until that terminal is closed. The same terminal is also used for **Run Python File in Terminal**. If that terminal is still running the REPL, you should exit the REPL (`exit()`) or switch to a different terminal before running a Python file.
42+
You can also run individual lines or a selection of code with the **Python: Run Selection/Line in Python Terminal** command (`kbstyle(Shift+Enter)`). If there isn't a selection, Smart Send will send the smallest runnable block of code around the line where your cursor is placed to the Python Terminal on (`kbstyle(Shift+Enter)`). An identical **Run Python > Run Selection/Line in Python Terminal** command is available on the context menu for a selection in the editor. The same terminal will be used every time you run a selection or a line in the terminal/REPL, until that terminal is closed. The same terminal is also used for **Run Python File in Terminal**. If that terminal is still running the REPL, you should exit the REPL (`exit()`) or switch to a different terminal before running a Python file.
4343

4444
The Python extension automatically removes indents based on the first non-empty line of the selection, shifting all other lines left as needed.
4545

46-
The command opens the Python Terminal if necessary; you can also open the interactive REPL environment directly using the **Python: Start REPL** command that activates a terminal with the currently selected interpreter and then runs the Python REPL.
46+
The command opens the Python Terminal if necessary; you can also open the interactive REPL environment directly using the **Python: Start Terminal REPL** command that activates a terminal with the currently selected interpreter and then runs the Python REPL.
4747

4848
For a more specific walkthrough and other ways of running code, see the [run code tutorial](/docs/python/python-tutorial.md).
4949

docs/python/python-tutorial.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,23 +142,25 @@ For full details on editing, formatting, and refactoring, see [Editing code](/do
142142

143143
## Run Python code
144144

145-
Click the **Run Python File in Terminal** play button in the top-right side of the editor.
145+
Click the **Run Python File** play button in the top-right side of the editor.
146146

147-
![Using the Run Python File in Terminal button](images/tutorial/run-python-file-in-terminal-button.png)
147+
![Using the Run Python File button](images/tutorial/run-python-file-in-terminal-button.png)
148148

149149
The button opens a terminal panel in which your Python interpreter is automatically activated, then runs `python3 hello.py` (macOS/Linux) or `python hello.py` (Windows):
150150

151151
![Program output in a Python terminal](images/tutorial/output-in-terminal.png)
152152

153153
There are three other ways you can run Python code within VS Code:
154154

155-
1. Right-click anywhere in the editor window and select **Run > Python File in Terminal** (which saves the file automatically):
155+
1. Right-click anywhere in the editor window and select **Run Python > Run Python File in Terminal** (which saves the file automatically):
156156

157157
![Run Python File in Terminal command in the Python editor](images/tutorial/run-python-file-in-terminal.png)
158158

159-
2. Select one or more lines, then press `kbstyle(Shift+Enter)` or right-click and select **Run Selection/Line in Python Terminal**. This command is convenient for testing just a part of a file.
159+
2. Select one or more lines, then press `kbstyle(Shift+Enter)` or right-click and select **Run Python > Run Selection/Line in Python Terminal**. Alternatively, you can activate Smart Send using `kbstyle(Shift+Enter)` without a selection and the Python extension will send the smallest runnable block of code near where your cursor is placed to the terminal. This command is convenient for testing just a part of a file.
160160

161-
3. From the Command Palette (`kb(workbench.action.showCommands)`), select the **Python: Start REPL** command to open a REPL terminal for the currently selected Python interpreter. In the REPL, you can then enter and run lines of code one at a time.
161+
> **Note**: If you prefer to send code at the particular line your cursor is placed, you can turn off Smart Send by setting `python.REPL.enableREPLSmartSend : "false"` in your **User** settings.
162+
163+
1. From the Command Palette (`kb(workbench.action.showCommands)`), select the **Python: Start Terminal REPL** command to open a REPL terminal (notated by `>>>`) for the currently selected Python interpreter. In the REPL, you can then enter and run lines of code one at a time.
162164

163165
Congrats, you just ran your first Python code in Visual Studio Code!
164166

0 commit comments

Comments
 (0)