The basic way to select a piece of text is to extend the selection with the mouse cursor. PyCharm, as a keyboard-centric IDE, suggests to use navigation keys to make selections. You can opt to select pieces of text by lines, or select rectangular fragments in the column mode, extend and shrink the selection, and use sticky selection.
In this section:
- Selecting all text in the active editor tab
- Selecting with navigation keys
- Extending selection
- Toggling between selection modes
- Using the column selection mode
- Using smart selection
- Toggling sticky selection
- On the main menu, choose .
- Press Ctrl+ACtrl+ACtrl+ACtrl+ACtrl+X, HCtrl+ACtrl+ACtrl+ACommand ACommand ACommand A.
- Ctrl+Shift+LeftCtrl+Shift+LeftCtrl+Shift+LeftCtrl+Shift+LeftCtrl+Shift+LeftCtrl+Shift+LeftCtrl+Shift+LeftShift+Alt+Left or Ctrl+Shift+LeftShift Alt LeftShift Alt LeftShift Alt Left, Ctrl+Shift+RightCtrl+Shift+RightCtrl+Shift+RightCtrl+Shift+RightCtrl+Shift+RightCtrl+Shift+RightCtrl+Shift+RightShift+Alt+Right or Ctrl+Shift+RightShift Alt RightShift Alt RightShift Alt Right to select text from the caret position to the beginning/end of the current word.
- Ctrl+Shift+Page UpCtrl+Shift+Page UpCtrl+Shift+Page UpCtrl+Shift+Page UpCtrl+Shift+Page UpCtrl+Shift+Page UpCtrl+Shift+Page UpCtrl+Shift+Page UpShift Command Page UpShift Command Page UpShift Command Page Up, Ctrl+Shift+Page DownCtrl+Shift+Page DownCtrl+Shift+Page DownCtrl+Shift+Page DownCtrl+Shift+Page DownCtrl+Shift+Page DownCtrl+Shift+Page DownCtrl+Shift+Page DownShift Command Page DownShift Command Page DownShift Command Page Down to select text from the caret position to the top/bottom of the screen.
- Press Ctrl+WCtrl+WCtrl+WCtrl+WCtrl+Alt+WCtrl+WShift+Alt+PeriodShift+Alt+UpAlt UpCommand WControl Shift Up to select the word where the caret is currently located.
- Press Ctrl+WCtrl+WCtrl+WCtrl+WCtrl+Alt+WCtrl+WShift+Alt+PeriodShift+Alt+UpAlt UpCommand WControl Shift Up successively to extend selection to the next containing node
(for example, an expression, a paired tag, an entire conditional block, a method body, a class, a group of vararg arguments, etc.)
While extending selection, keep in mind the following:
- Pressing Ctrl+WCtrl+WCtrl+WCtrl+WCtrl+Alt+WCtrl+WShift+Alt+PeriodShift+Alt+UpAlt UpCommand WControl Shift Up successively in plain text or comments extends the selection first to the current sentence, then to the current paragraph.
- Pressing Ctrl+WCtrl+WCtrl+WCtrl+WCtrl+Alt+WCtrl+WShift+Alt+PeriodShift+Alt+UpAlt UpCommand WControl Shift Up successively inside a list, dictionary, or a list of arguments or parameters, selects an element of the list, then the right or left comma and a neighbouring space (if any), then the contents of the list without parentheses, and finally the enclosing parentheses.
Press Ctrl+Shift+WCtrl+Shift+WCtrl+Shift+WCtrl+Shift+WCtrl+Shift+WCtrl+Shift+WShift+Alt+CommaShift+Alt+DownAlt DownShift Command WControl Shift Down to shrink selection in the reverse order (from the outermost container to the word where the caret currently resides).
The selection extends or shrinks according to capitalization, if the Use "CamelHumps" words is enabled on the Editor. Smart Keys settings page.
If you want to make selection according to capitalization, using double-click, make sure that the option Honor CamelHumps words... is selected on the Editor settings page.
- On the main menu, choose .
- On the context menu of the editor, choose .
- Press Shift+Alt+InsertShift+Alt+InsertShift+Alt+InsertShift+Alt+InsertShift+Alt+InsertShift+Alt+InsertShift+Alt+InsertShift+Alt+InsertShift Command 8Shift Command NumPad *Shift Command 8.
- Keeping the middle mouse button pressed, drag the mouse.
- Keeping the Alt key pressed, drag your mouse pointer to select the desired area.
- Keeping the middle mouse button pressed, drag your mouse pointer to select the desired area.
The procedure for the Introduce Variable refactoring is just an example. The smart expression selection feature, in fact, is available in all the refactorings that start with selecting an expression.
Place the cursor before or within the expression.
- Choose Ctrl+Alt+VCtrl+Alt+VShift+Alt+VCtrl+Alt+VCtrl+Alt+VCtrl+Alt+VShift+Alt+VShift+Alt+L or Ctrl+Alt+VAlt Command VAlt Command VAlt Command L. from the main or the context menu, or press
In the Expressions pop-up menu, select the expression.
To do that, click the required expression. Alternatively, use the Up and Down arrow keys
to navigate to the expression of interest, and then press EnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnter to select it.
- Press Ctrl+Shift+ACtrl+Shift+ACtrl+Shift+ACtrl+Shift+ACtrl+Shift+ACtrl+Shift+ACtrl+ICtrl+Shift+AShift Command AShift Command ACommand 3, in the pop-up frame type sticky, and choose Toggle Sticky Selection from the suggestion list:
- In the Emacs keymap, use keyboard shortcut Ctrl+SpaceCtrl+SpaceCtrl+SpaceCtrl+SpaceAlt+SlashCtrl+SpaceCtrl+Space or Ctrl+Back SlashCtrl+SpaceControl SpaceControl SpaceControl Space.
When sticky selection is on, you can turn it off by invoking copy or cut, or by toggling it again.