Make and Extend Selection Using Keyboard

Use the keyboard to select blocks of code then extend/shrink the selection.

In coding, we select code and operate on it. For example, move it to another line, change its indentation, etc.

You can use your mouse to make your selection. Or, use the keyboard.

For example, use Move Caret to Previous Word with Selection ⌥⇧← (macOS) / Ctrl+Shift+Left Arrow (Windows/Linux) to (a) move the cursor forward or backward a word, while (b) expanding the selection along the way. Want to select three words? Do it three times.

In Python code you frequently want to gradually expand a selection from where the cursor is at: the symbol, then the substatement, then the full statement, then the line, then the block, etc. ⌥↑ (macOS) / Ctrl+W (Windows/Linux) is ideal. It works semantically. Keep pressing it until you get the selection you want. Go too far? Do the inverse to shrink the selection.

Without using the mouse.

Finally, PyCharm also supports multiselection aka multiple carets.

Interested in another cool selection tip?

call to action image

You can wrap a selection with a tag to save your fingers. Check it out!

Learn More


Related Resources

Navigation Bar - All the power!
Navigation Bar - All the power!
The Navigation Bar can do much more than you think!
Clean Up Messy Imports With Optimize Imports
Clean Up Messy Imports With Optimize Imports
Quickly remove any unused imports and more.
Find in Path with the Navigation Bar
Find in Path with the Navigation Bar
Use the Navigation bar and Find in File together and be faster than all of your team members.