PyCharm: превращение выделения в несколько курсоров в строке
Sublime Text имеет эту функцию, где вы можете выделить текст и начать редактирование каждой строки с помощью (многократного) курсора:
Есть ли эквивалент PyCharm?
11 ответов
-
Нажмите Shift + Alt и нажмите LEFT кнопка мыши в месте расположения каретки.
-
Дважды щелкните Ctrl и нажмите клавиши со стрелками вверх или вниз .
На OSX, кажется, достаточно нажать LEFT — ALT и добавить новые каретки с помощью мыши LEFT CLICK или нажмите SHIFT + ALT и нарисуйте курсоры с помощью мыши.
Другой вариант: с выделенным текстом, переключить режим выбора столбца:
Ярлык по умолчанию для переключения режима:
- Linux / Windows: alt — shift — insert
- макинтош cmd — shift — (numpad) *
(или же Edit → Column Selection Mode )
Это неудобный ярлык для Mac, так как большинство ноутбуков не имеют цифровой клавиатуры. Я переназначил это cmd — shift — 8 ,
Режим выбора столбцов на самом деле имеет и другие цели: он меняет поведение по умолчанию при выделении текста с помощью клавиатуры и мыши. Отключите его снова, чтобы вернуться к нормальному поведению выбора.
Multiple cursors and selection ranges
When typing, copying, or pasting in PyCharm editor, you can toggle multiple cursors so that your actions apply in several places simultaneously. Advanced editor actions, such as code completion and live templates are supported as well and will apply to each caret.
The number of carets that you can add in a file is limited to 1000. If you want to increase that limit, open the custom JVM options Help | Edit Custom VM Options and add the following line: -Deditor.max.caret.count=<NEW_LIMIT> .
The most recently added caret is considered primary . Highlighting of the current editor line, completion lists, and other visual assistance features will apply to the primary caret. This caret will also remain when you turn off multiple carets.
Add and remove carets
You can add carets in two different ways:
To existing characters
Using virtual spaces
If there is no character, tab, or whitespace at the position where you want to add a new caret, the new caret will be added to the last character position in the target line.
This way you can add new carets anywhere after the last character in any line. As soon as you start typing at a position beyond the end of the line, the necessary number of spaces will be added between the end of the line and the beginning of your input.
You can enable virtual spaces on the Editor | General page of the IDE settings Control+Alt+S and they are also enabled in the column selection mode.
Add or remove carets at selected locations using mouse
Alt+Shift+LeftClick at the target location to add another caret.
Alt+Shift+LeftClick at one of the multiple carets to remove it. The last caret will not be removed.
Add carets above or below the current caret using keyboard
Press Control twice, and then without releasing it, press up or down arrow keys.
If virtual spaces are enabled, new carets will be added exactly above or below the current caret position. Otherwise, in lines, which are shorter than the current offset, carets will be added at line ends.
Enable the column selection mode (press Alt+Shift+Insert ) and then press Shift+ArrowUp / Shift+ArrowDown .
Press Control+Shift+A , type Clone caret , and choose the desired action from the suggestion list:

Note that by default these actions are not associated with keyboard shortcuts. You can assign your custom shortcuts to these actions as described in configuring keyboard shortcuts.
Add carets at each line of the current document
Press Control+Home to set the caret at the beginning of the first line, enable the column selection mode (press Alt+Shift+Insert ), and then press Control+Shift+End .
Add carets to the end of each line in the selected block
Select a code block in the editor and then press Alt+Shift+G .
Remove multiple carets
Press Esc to delete all existing carets, except the one that was added last.
Alt+Shift+LeftClick at one of the multiple carets to remove it. The last caret will not be removed.
Select multiple non-contiguous ranges
When you select multiple text ranges (non-contiguous selection), note the following:
Each selection range is associated with its own caret, so you can start typing to replace all selected ranges with your input, or you can press Left Arrow or Right Arrow to remove the selection ranges but keep multiple carets at beginnings/ends of the ranges.
As soon as selection ranges overlap, they are merged into a single selection range with a single caret.
Selection works independently of the code structure, that is selection ranges can include any characters, identifiers, words in string literals, comments, or their parts. So you have to be careful when changing the selected ranges as they may include different identifiers or their parts.
Select multiple words or text ranges
While Alt+Shift+LeftClick will add a new caret, double-clicking words or dragging the mouse over text ranges (keeping the same keys pressed) will add new carets with the corresponding selections.
Select multiple occurrences of a word or a text range
If you want to select words, set your caret at an occurrence of the desired word. Otherwise, select the desired range with the mouse or with keyboard shortcuts .
Do one of the following:
Successively press Alt+J to find and select the next occurrence of case-sensitively matching word or text range.
Press Control+Alt+Shift+J to select all case-sensitively matching words or text ranges in the document.
To remove selection from the last selected occurrence, press Alt+Shift+J .
After the second or any consecutive selection was added with Alt+J , you can skip it and select the next occurrence with F3 . To return the selection to the lastly skipped occurrence, press Shift+F3 .
Find and select multiple occurrences of a string
Press Control+F or choose Edit | Find | Find from the main menu. The search pane appears at the top of the active editor.
Enter the string that you want to find and select. To the right of the search string, you will see the number of occurrences in the current document.
Optionally, restrict your search by case Alt+C or to match only whole words Alt+W .
Press Control+Alt+Shift+J or click Select All Occurrences on the toolbar.
Use mouse to select rectangular fragments of text in normal selection mode
Make sure that the column selection mode is disabled .
To select ranges as a single rectangle, do one of the following:
Set the caret at one corner of the rectangle, and then Alt+Shift+MiddleClick at the diagonally opposite corner.
Alt+LeftClick and drag the mouse to make the selection.
To select ranges as multiple rectangular selections, Control+Alt+Shift+LeftClick and drag the mouse over the desired parts of code.
As a result, you will have multiple selection ranges in each affected document line. On lines that are shorter than the rectangle, the selection will only span to the last character.
Column selection mode
In the column selection mode , keyboard navigation and selection shortcuts in the current document work differently to simplify adding multiple carets and making rectangular selections:
You will be able to set your caret anywhere after the last character in any line. As soon as you start typing at a position beyond the end of the line, the necessary number of spaces will be added between the end of the line and the beginning of your input.
You can also enable this in the normal selection mode — select Allow placement of caret after end of line on the Editor | General page of the IDE settings Control+Alt+S .
Pressing Shift+ArrowUp / Shift+ArrowDown or dragging the mouse up and down will add new carets above/below the current one instead of making a continuous selection.
The enabled column selection mode only affects the current editor tab. If you close or reopen the tab, it will switch back to the normal mode.
If the column selection mode is enabled for the current document, the Column indicator is displayed on the status bar.
Toggle between normal and column selection modes
From the main menu, choose Edit | Column Selection Mode .
From the context menu of the editor, choose Column Selection Mode .
Copy and paste with multiple carets
When text ranges selected with multiple carets are copied Control+C or cut Control+X , selections for each caret are placed to the clipboard as separate lines, even if the original selections were on the same line.
If the column selection mode was enabled, the selection could also include empty spaces after ends of lines. These will be replaced with whitespaces in the clipboard if you copy the selection.
When you paste any multi-line content from the clipboard, you can add multiple carets for each line in desired places, and then press Control+V to paste each line at its own caret.
Горячие клавиши pycharm
Есть ли в pycharm функция множественного выделения как в sublime text(можно поставить много курсоров и одновременно в разных строках редактировать текст, в sublime Ctrl + клик мышкой). А также очень не хватает возможности быстро выделить одинаковое слово, в sublime — Ctrl + D . А также как вы решаете проблему одинаковых сочетаний горячих клавиш в линкусе и в самом пайчарме, например Ctrl + Alt + l в pycharm должен запустить reformat code но в линуксе это блокирует экран.
Ответы (6 шт):
можно поставить много курсоров и одновременно в разных строках редактировать текст, в sublime ctrl + клик мышкой
Alt, если правильно помню
очень не хватает возможности быстро выделить одинаковое слово, в sublime — ctrl + D.
Как оказалось, у меня просто была версия pycharm 3.1, а фича мультивыделения появилась в 3.4, после обновления все прекрасно работает.
У меня стоят настройки от Visual Studio, но Keymap->Editor Actions->Column Selection Mode стоит Alt+Shift+Insert .
Нажимаешь, потом выделяешь несколько строк Shift+Up/Down .
Можно так попробовать: Ctrl + Alt + Shift
Есть ли в pycharm функция множественного выделения как в sublime text(можно поставить много курсоров и одновременно в разных строках редактировать текст, в sublime Ctrl + клик мышкой)
Как в pycharm писать сразу на нескольких строках
When typing, copying, or pasting in PyCharm editor, you can toggle multiple cursors so that your actions apply in several places simultaneously. Advanced editor actions, such as code completion and live templates are supported as well and will apply to each caret.
The number of carets that you can add in a file is limited to 1000. If you want to increase that limit, open the custom JVM options Help | Edit Custom VM Options and add the following line: -Deditor.max.caret.count=<NEW_LIMIT> .
The most recently added caret is considered primary . Highlighting of the current editor line, completion lists, and other visual assistance features will apply to the primary caret. This caret will also remain when you turn off multiple carets.
Add and remove carets
You can add carets in two different ways:
To existing characters
Using virtual spaces
If there is no character, tab, or whitespace at the position where you want to add a new caret, the new caret will be added to the last character position in the target line.
This way you can add new carets anywhere after the last character in any line. As soon as you start typing at a position beyond the end of the line, the necessary number of spaces will be added between the end of the line and the beginning of your input.
You can enable virtual spaces on the Editor | General page of the IDE settings Ctrl+Alt+S and they are also enabled in the column selection mode.
Add or remove carets at selected locations using mouse
Alt+Shift+Click at the target location to add another caret.
Alt+Shift+Click at one of the multiple carets to remove it. The last caret will not be removed.
Add carets above or below the current caret using keyboard
Press Ctrl twice, and then without releasing it, press up or down arrow keys.
If virtual spaces are enabled, new carets will be added exactly above or below the current caret position. Otherwise, in lines, which are shorter than the current offset, carets will be added at line ends.
Enable the column selection mode (press Alt+Shift+Insert ) and then press Shift+Up / Shift+Down .
Press Ctrl+Shift+A , type Clone caret , and choose the desired action from the suggestion list:

Note that by default these actions are not associated with keyboard shortcuts. You can assign your custom shortcuts to these actions as described in configuring keyboard shortcuts.
Add carets at each line of the current document
Press Ctrl+Home to set the caret at the beginning of the first line, enable the column selection mode (press Alt+Shift+Insert ), and then press Ctrl+Shift+End .
Add carets to the end of each line in the selected block
Select a code block in the editor and then press Alt+Shift+G .
Remove multiple carets
Press Esc to delete all existing carets, except the one that was added last.
Alt+Shift+Click at one of the multiple carets to remove it. The last caret will not be removed.
Select multiple non-contiguous ranges
When you select multiple text ranges (non-contiguous selection), note the following:
Each selection range is associated with its own caret, so you can start typing to replace all selected ranges with your input, or you can press Left Arrow or Right Arrow to remove the selection ranges but keep multiple carets at beginnings/ends of the ranges.
As soon as selection ranges overlap, they are merged into a single selection range with a single caret.
Selection works independently of the code structure, that is selection ranges can include any characters, identifiers, words in string literals, comments, or their parts. So you have to be careful when changing the selected ranges as they may include different identifiers or their parts.
Select multiple words or text ranges
While Alt+Shift+Click will add a new caret, double-clicking words or dragging the mouse over text ranges (keeping the same keys pressed) will add new carets with the corresponding selections.
Select multiple occurrences of a word or a text range
If you want to select words, set your caret at an occurrence of the desired word. Otherwise, select the desired range with the mouse or with keyboard shortcuts .
Do one of the following:
Successively press Alt+J to find and select the next occurrence of case-sensitively matching word or text range.
Press Ctrl+Alt+Shift+J to select all case-sensitively matching words or text ranges in the document.
To remove selection from the last selected occurrence, press Alt+Shift+J .
After the second or any consecutive selection was added with Alt+J , you can skip it and select the next occurrence with F3 . To return the selection to the lastly skipped occurrence, press Shift+F3 .
Find and select multiple occurrences of a string
Press Ctrl+F or choose Edit | Find | Find from the main menu. The search pane appears at the top of the active editor.
Enter the string that you want to find and select. To the right of the search string, you will see the number of occurrences in the current document.
Optionally, restrict your search by case Alt+C or to match only whole words Alt+W .
Press Ctrl+Alt+Shift+J or click Select All Occurrences on the toolbar.
Use mouse to select rectangular fragments of text in normal selection mode
Make sure that the column selection mode is disabled .
To select ranges as a single rectangle, do one of the following:
Set the caret at one corner of the rectangle, and then Alt+Shift+Middle-Click at the diagonally opposite corner.
Alt+Click and drag the mouse to make the selection.
To select ranges as multiple rectangular selections, Ctrl+Alt+Shift+Click and drag the mouse over the desired parts of code.
As a result, you will have multiple selection ranges in each affected document line. On lines that are shorter than the rectangle, the selection will only span to the last character.
Column selection mode
In the column selection mode , keyboard navigation and selection shortcuts in the current document work differently to simplify adding multiple carets and making rectangular selections:
You will be able to set your caret anywhere after the last character in any line. As soon as you start typing at a position beyond the end of the line, the necessary number of spaces will be added between the end of the line and the beginning of your input.
You can also enable this in the normal selection mode — select Allow placement of caret after end of line on the Editor | General page of the IDE settings Ctrl+Alt+S .
Pressing Shift+Up / Shift+Down or dragging the mouse up and down will add new carets above/below the current one instead of making a continuous selection.
The enabled column selection mode only affects the current editor tab. If you close or reopen the tab, it will switch back to the normal mode.
If the column selection mode is enabled for the current document, the Column indicator is displayed on the status bar.
Toggle between normal and column selection modes
From the main menu, choose Edit | Column Selection Mode .
From the context menu of the editor, choose Column Selection Mode .
Copy and paste with multiple carets
When text ranges selected with multiple carets are copied Ctrl+C or cut Ctrl+X , selections for each caret are placed to the clipboard as separate lines, even if the original selections were on the same line.
If the column selection mode was enabled, the selection could also include empty spaces after ends of lines. These will be replaced with whitespaces in the clipboard if you copy the selection.
When you paste any multi-line content from the clipboard, you can add multiple carets for each line in desired places, and then press Ctrl+V to paste each line at its own caret.
Горячие клавиши pycharm
Есть ли в pycharm функция множественного выделения как в sublime text(можно поставить много курсоров и одновременно в разных строках редактировать текст, в sublime Ctrl + клик мышкой). А также очень не хватает возможности быстро выделить одинаковое слово, в sublime — Ctrl + D . А также как вы решаете проблему одинаковых сочетаний горячих клавиш в линкусе и в самом пайчарме, например Ctrl + Alt + l в pycharm должен запустить reformat code но в линуксе это блокирует экран.
Ответы (6 шт):
можно поставить много курсоров и одновременно в разных строках редактировать текст, в sublime ctrl + клик мышкой
Alt, если правильно помню
очень не хватает возможности быстро выделить одинаковое слово, в sublime — ctrl + D.
Как оказалось, у меня просто была версия pycharm 3.1, а фича мультивыделения появилась в 3.4, после обновления все прекрасно работает.
У меня стоят настройки от Visual Studio, но Keymap->Editor Actions->Column Selection Mode стоит Alt+Shift+Insert .
Нажимаешь, потом выделяешь несколько строк Shift+Up/Down .
Можно так попробовать: Ctrl + Alt + Shift
Есть ли в pycharm функция множественного выделения как в sublime text(можно поставить много курсоров и одновременно в разных строках редактировать текст, в sublime Ctrl + клик мышкой)
PyCharm: Turning selection to multiple cursors per line
Sublime Text has this functionality where you can select text and start editing each line with a (multiple) cursor:
Is there PyCharm equivalent?
12 Answers 12
Another option: with text selected, toggle column selection mode:
The default shortcut to toggle the mode is:
- Linux/Windows: alt — shift — insert
- Mac cmd — shift — (numpad) *
(or Edit → Column Selection Mode )
It’s an inconvenient shortcut for Mac, as most laptops have no numpad. I remapped it to cmd — shift — 8 .
Column selection mode actually has other purposes too: it changes the default behavour when selecting text with the keyboard and mouse. Toggle it off again to return to normal selection behaviour.
Как поставить курсор в нескольких местах?
Вы можете просто Alt нажать + для дополнительных курсоров. И , как уже упоминалось, Ctrl + Alt + ↑ или ↓ . И вы можете использовать Alt + Shift + щелчок, чтобы выбрать две строки и каждую строку между ними.
Как поставить несколько курсоров Vscode?
- 1) Добавить курсор над/под (CTRL+ALT+↑/↓) .
- 3) Добавить множественные курсоры ко всем вхождениям выделенного текста (CTRL+SHIFT+L) .
- 4) Отменить последнюю операцию курсора (CTRL+U) .
- 1) Поиск файла (CTRL + P) .
- 2) Поиск символа (CTRL + T) .
- 3) Поиск локального символа (CTRL + SHIFT + O)
Как размножить курсор Vscode?
- Зажмите Alt (в Windows) или ⌥Option (в macOS) и кликайте левой кнопкой мышки там, куда нужно добавить курсор.
- Выделите несколько строк, зажав среднюю кнопку мыши. .
- Если лень кликать мышкой, то дублировать курсор можно так: Ctrl + Alt + ↑ / ↓ (Windows) или ⌥Option + ⌘Cmd + ↑ / ↓ (macOS).
Как писать сразу в нескольких строках Sublime?
Единственный способ сделать многострочный курсор в Sublime text 3-Это Ctrl+Shift+RC+Drag.
Как писать сразу в несколько строк Visual Studio?
- Вы можете использовать Shift + Alt при щелчке левой кнопкой мыши, но это будет хорошо только для выбора нескольких строк .
- Вопрос может быть датирован, но в Visual Studio 2019 году, удерживая его .
- Вы можете сделать это в Visual Studio Code, так как он основан на Atom.
Как поменять горячие клавиши в Visual Studio?
Нажмите CTRL+SHIFT+P или F1, чтобы открыть панель команд и введите keyboard shortcuts. Далее вы увидите как минимум две записи. Откройте файл с горячими клавишами по умолчанию (JSON). Там Visual Studio Code сохраняет все клавиши по умолчанию и список свободных соединений, доступных для использования.
Как удалить строку в VS Code?
- Перейти на строку, которую вы хотите удалить
- Нажмите «Дом»
- Затем «Shift» + «Конец»
- Тогда ‘Del’
- и снова «Del»
Как в Pycharm выделить несколько строк?
- ctrl+w просто выделяет слово, строку, блок, в зависимости сколько раз нажмешь, в sublime text если нажать ctrl + D (при выделенном слове или символе) выделялось следующее слово в файле которое соответствует выделенному. – СергейСион 15 ноя ’14 в 17:35.
- alt + j выделяет все похожие слова – Andru 7 мар ’20 в 0:31.
Как выделить несколько элементов в VS Code?
- Windows, Ubuntu — Ctrl + Shift + стрелка вправо / влево
- Mac — Command + Shift + стрелка вправо / влево
Как в HTML выделить несколько строк?
Если нужны несколько строк, идущих подряд, выделите начальную строку и при нажатой клавише Shift выберите конечную строку.
Как переключаться между вкладками VS Code?
Переключиться между вкладками: Ctrl + Tab.
Как закомментировать код в Visual Studio Code?
- F2 — переименовать символ (функцию, переменную и т. .
- Ctrl + Shift + O — перейти к символу;
- Ctrl + K Z — перейти в режим Дзен, в котором вас не отвлекают лишние детали;
- Ctrl + / — закомментировать/раскомментировать строку;
- Shift + Alt + A — закомментировать/раскомментировать блок кода;
Как выровнять текст в Visual Studio?
Форматировать фрагмент кода — жмёшь Ctrl + K, отпускаешь и сразу жмёшь Ctrl + F. Форматировать весь код — жмёшь Ctrl + K, отпускаешь и сразу жмёшь Ctrl + D. // эта функция не всегда доступна. Помощь в написании контрольных, курсовых и дипломных работ здесь.