Feature Spotlight: Multiple Selections in PyCharm
Today I’d like to highlight one of the most top voted features that appeared in PyCharm 3.4 some time ago – Multiple Selections. Since then a lot of people have been using it and enjoying the increased productivity while editing.
With this feature you can:
- Set multiple cursors in the editor area: Alt + Mouse Click (Option + Mouse Click for Mac OS X). Note that on some systems you also have to use Shift with the shortcuts mentioned.
- Select/unselect the next occurrence: Alt + J / Shift + Alt + J (Ctrl + G / Shift + Ctrl +G for Mac OS X)
- Select all occurrences: Shift + Ctrl + Alt + J (Ctrl + Cmd + G for Mac OS X)
- Clone caret above/below (the shortcuts are not mapped yet)
- Remove all selections: Esc
You can redefine these shortcuts in Settings -> Keymap -> Editor Actions if necessary.
Multiple selections work nicely together with other PyCharm features like Code completion, Select word at caret, Join lines, Copy/paste, and the others. This feature also works with all languages supported by PyCharm such as Python, HTML, JavaScript, CSS and more.
Hope you’ll enjoy this handy feature!
-Dmitry
Comments below can no longer be edited.
TM says:
September 16, 2014What’s really missing is an option to skip an occurrence when using ALT+J. Someone in the bugtracker mentioned that F3 does this, but F3 uses the current search term. ALT+J doesn’t – it uses whatever the cursor is currently on / whatever is currently selected (which is useful).
Ralph says:
September 17, 2014Hi Dmitry,
very nice post – feel free to write more of those little tips 😉 It’s a good and crisp way to learn more about those awesome PyCharm features.
Ralph
Steve Piercy says:
September 17, 2014On Mac, I found that Option+Shift+Click works, but not just Option+Click.
Also there is no ALT on Mac, but it usually maps to Option.
Dmitry Filippov says:
September 17, 2014Hi Steve,
ok, “Option+Shift+Click” which version of PyCharm are you using? We’ve been changing the shortcut from Option + Click to Option + Shift + Click and back.
Nik Molnar says:
September 17, 2014It seems to be Shift + Alt + Click (not just Alt + Click) to set multiple cursors for me on Windows. I am at 3.4.1 and haven’t changed any of the default key bindings.
Jason Ansel says:
September 18, 2014Too bad this feature broke vim bindings. Great vim bindings are the #1 reason I use pycharm. I downgraded pycharm to get rid of this feature and fix vim bindings.
http://youtrack.jetbrains.com/issue/VIM-632
E-MMOP says:
May 24, 2015Hello,
when you searched with spotlight on maverick, you can do a ALT+CLICK to search in finder where is file. But in Yosemite this function is out …
Have you a tips for it ?
Ev says:
July 3, 2019For some reason I cannot get the Alt+Button Click to work. It is set in my Keymap and it worked like once before, but now I can’t get it to work. Any ideas about how to fix this?
Koby says:
April 8, 2020The youtube video link doesn’t work anymore