Thirumalai vasan
Thirumalai vasan

Reputation: 793

What is the shortcut key to comment multiple lines using PyCharm IDE?

In Corey Schafer's Programming Terms: Mutable vs Immutable, at 3:06, he selected multiple lines and commented them out in PyCharm all in one action.

What is this action? Is it a built-in shortcut in PyCharm that I can use or configure myself?

Upvotes: 32

Views: 153407

Answers (9)

wadoud azer
wadoud azer

Reputation: 1

if you are familliar with vscode shortcuts for this case ctrl+k ctrl+c for comment and ctrl+k ctrl+u for uncomment , you can go to settings icon in the top bar , then to keymap then to "Install Keymap" , then you find Visual Studio Keymap , and thats it I wish it help

Upvotes: 0

Dibyajyoti Das
Dibyajyoti Das

Reputation: 1

Highlight the region and type Ctrl+'. This is better than the Ctrl+/ which puts a # infront of every line.

Upvotes: -4

Ardeshir Mazaheri
Ardeshir Mazaheri

Reputation: 29

this is not the shortcut but an alternative: using 3 single (''') or double quotation marks (""") in the beginning and also at the end of a bunch of lines.

Upvotes: 2

maxe585
maxe585

Reputation: 49

For a QWERTY keyboard layout you can use Ctrl + NumPad / to comment something out

Upvotes: 4

fgriset
fgriset

Reputation: 159

Years later: on AZERTY keyboard, '/' from syntax area (;.:/!§,?), AKA "slash" does not work! You have to use the '/' symbol from numbers area (division symbol).

Upvotes: 15

Tuncay Elvanagac
Tuncay Elvanagac

Reputation: 1342

If you use macbook build-in keyboard, this shortcut does not work. So you can assign new shortcut for this purpose by following steps;

1.Go keymap menu

PyCharm -> Preferences -> Keymap

2.Find "comment with line comment" then click pencil sign "add keyboard shortcut" then assign your custom shortcut (press your favorite keyboard combination)

Upvotes: 2

ShlomiF
ShlomiF

Reputation: 2905

This is a setting you can change and define in "Settings".

The default is with Ctrl+/ for Windows, or Cmd+/ for Mac.

Upvotes: 65

Ma7
Ma7

Reputation: 229

Is depends on you're text editor , but probably all text editor use (ctrl + /) just highlight all the code you need to comments and use the shortcut , to know what shortcut using in you're favorite text editor search in google : YourTextEditor shortcuts

Upvotes: 2

Mart R
Mart R

Reputation: 1

This heavily depends on where you're writing your python code. If you're writing it in Notepad, there won't be a shortcut for commenting a line.

However, if you use an IDE, you will probably have such capability alongside the ability to change the shortcut. Just search Google for keyboard shortcuts for your preferred IDE.

Upvotes: -5

Related Questions