Как убрать зеленое выделение pycharm
Приёмы работы в PyCharm
Введение
PyCharm — интегрированная среда разработки для языка программирования Python. Предоставляет средства для анализа кода, графический отладчик, инструмент для запуска юнит-тестов и поддерживает веб-разработку на Django. PyCharm разработана компанией JetBrains на основе IntelliJ IDEA.
PyCharm — это кросс-платформенная среда разработки, которая совместима с Windows, macOS, Linux. PyCharm Community Edition (бесплатная версия) находится под лицензией Apache License, а PyCharm Professional Edition (платная версия) является проприетарным ПО.
Установка в Linux
Скачать с официального сайта jetbrains
Либо с помощью wget
Запустите JetBrains Toolbox
Примите JETBRAINS USER AGREEMENT
Выберите PyCharm Community или PyCharm Professional
Установить модуль в PyCharm
Рассмотрим как устанавливать дополнительные модули и библиотеки в PyCharm на примере requests
Перейдите в настройки проекта нажав
Найдите раздел Project: название вашего проекта
Выберите подраздел Project Interpreter или Python Interpreter
Нажмите на плюс в правой части экрана
Должно появиться окно Available Packages
Введите в стоку поиска название нужного модуля. В моём случае это requests
Нажмите кнопку Install Package
Дождитесь окончания установки
Дождитесь окончания установки
Pycharm: поставить курсор в начало нескольких строк подряд
Если нужно добавить или удалить что-то из нескольких срок, которые идут подряд
Поставьте курсор в нужное место самой верхней строки
Нажмите CTRL затем ещё раз CTRL и не отпускайте его. Нажмите стрелку вниз нужное количество раз.
Вертикальная линия ограничитель длины строки
Вертикальная линия после определённого числа символов помогает понять, что строка стала слишком длинной.
PEP 8 ограничивает длину 79 символами.
Limit all lines to a maximum of 79 characters.
For flowing long blocks of text with fewer structural restrictions (docstrings or comments), the line length should be limited to 72 characters.
Документация к Django рекомендует длину строки до 119 символов. Это связано с ограничением в GitHub
An exception to PEP 8 is our rules on line lengths. Don’t limit lines of code to 79 characters if it means the code looks significantly uglier or is harder to read.
We allow up to 119 characters as this is the width of GitHub code review; anything longer requires horizontal scrolling which makes review more difficult.
This check is included when you run flake8. Documentation, comments, and docstrings should be wrapped at 79 characters, even though PEP 8 suggests 72.
Популярный Python линтер Black ограничивает длину 88 символами.
Установить положение вертикальной линии в PyCharm можно в
File → Settings → Editor → Code Style → Hard wrap at
Разделить окно на две части
Разделить окно на две части можно разными способами
Половина слева, половина справа: выберите нужную вкладку → сделайте правый клик → Split Right
Половина снизу, половина сверху: выберите нужную вкладку → сделайте правый клик → Split Down
Чтобы просто перенести вкладку на новую половину экрана выберите Split and Move Right или Split and Move Down
Переключение из терминала
Чтобы быстро переключаться между терминалом и редактором кода можно воспользоваться следующим способом
Терминал будет скрыт если активен и появится если скрыт. Курсор автоматически переходит туда-сюда.
Убрать зеленый фон у кода в PyCharm
Если в код вставлен фрагмент на другом языке, PyCharm может подсветить его зелёным.
Если такого кода много, читать становится неприятно.
Особенно это актуально для Dockerfile
Решить проблему можно отключив подсветку в injected language fragment
Settings → Editor → Color Schema → General
injected language fragment
injected language fragment
Закомментировать выделенный код
Чтобы закомментировать выделенный код нажмите
Точно также выделенную область можно раскомментировать
Переименовать функцию в файле
Чтобы быстро переименовать функцию внутри файла выделите название функции и нажмите
Снизу справа появится превью. Изучите если нужно и нажмите Do Refactor снизу слева.
File Status Highlights
In PyCharm, each file is marked with a color according to its state in the version control you are using.
In the editor, each line in a file is checked for its version control state and is marked with a color in the gutter.
File status
To highlight folders and packages with modified contents, go to Settings/Preferences | Version Control | Confirmation and enable the Highlight directories that contain modified files in the Project tree option.
#0A7700
The file in the active changelist is scheduled for addition to the repository.
#0EAA00
Added in not active changelist
#FF0000
#0A7700
#616161
The file is scheduled for deletion from the repository.
#773895
Deleted from file system
The file has been deleted locally, but hasn’t been scheduled for deletion, and it still exists in the repository.
#8AA4C8
Have changed descendants
#3264B4
Have immediate changed children
#B28C00
[Perforce, ClearCase, VSS] The file is modified without checkout.
#727238
A file is intentionally untracked by VCS.
#7503DC
The file is merged by your VCS as a result of an update.
#FF0000
Merged with conflicts
During the last update, the file has been merged with conflicts.
#FF0000
Merged with property conflicts
During the last update, the IDE has detected differences between the properties of the local file and its server version.
#FF0000
Merged with text and property conflicts
Text and property conflicts happen when two or more developers modify the same lines of a file and the same file properties.
#0032A0
The file has changed since the last synchronization.
#0047E4
Modified in not active changelist
#7C7C00
The file should no longer be in your working copy of the repository.
#007C7C
Since the last update, the file has been renamed.
#08978F
[SVN] The file is taken from a different branch than the whole project.
#993300
The file exists locally, but is not in the repository, and is not scheduled for addition.
None (default color)
The file hasn’t been changed.
#629755
The file in the active changelist is scheduled for addition to the repository.
#629755
Added in not active changelist
#D5756C
#0A7700
#6C6C6C
The file is scheduled for deletion from the repository.
#6C6C6C
Deleted from file system
The file has been deleted locally, but hasn’t been scheduled for deletion, and it still exists in the repository.
#6897BB
Have changed descendants
#6897BB
Have immediate changed children
None (default color)
[Perforce, ClearCase, VSS] The file is modified without checkout.
#848504
A file is intentionally untracked by VCS.
#9876AA
The file is merged by your VCS as a result of an update.
#D5756C
Merged with conflicts
During the last update, the file has been merged with conflicts.
#D5756C
Merged with property conflicts
During the last update, the IDE has detected differences between the properties of the local file and its server version.
#D5756C
Merged with text and property conflicts
Text and property conflicts happen when two or more developers modify the same lines of a file and the same file properties.
#6897BB
The file has changed since the last synchronization.
#6897BB
Modified in not active changelist
None (default color)
The file should no longer be in your working copy of the repository.
#3A8484
Since the last update, the file has been renamed.
None (default color)
[SVN] The file is taken from a different branch than the whole project.
#D1675A
The file exists locally, but is not in the repository, and is not scheduled for addition.
None (default color)
The file hasn’t been changed.
#62CC47
The file in the active changelist is scheduled for addition to the repository.
#62CC47
Added in not active changelist
#FF6666
#62CC47
#ED864A
The file is scheduled for deletion from the repository.
#ED864A
Deleted from file system
The file has been deleted locally, but hasn’t been scheduled for deletion, and it still exists in the repository.
#4FF0FF
Have changed descendants
#4FF0FF
Have immediate changed children
None (default color)
[Perforce, ClearCase, VSS] The file is modified without checkout.
#A9B837
A file is intentionally untracked by VCS.
#ED94FF
The file is merged by your VCS as a result of an update.
#FF6666
Merged with conflicts
During the last update, the file has been merged with conflicts.
#FF6666
Merged with property conflicts
During the last update, the IDE has detected differences between the properties of the local file and its server version.
#FF6666
Merged with text and property conflicts
Text and property conflicts happen when two or more developers modify the same lines of a file and the same file properties.
#4FF0FF
The file has changed since the last synchronization.
#4FF0FF
Modified in not active changelist
None (default color)
The file should no longer be in your working copy of the repository.
#4FF0FF
Since the last update, the file has been renamed.
None (default color)
[SVN] The file is taken from a different branch than the whole project.
D1675A
The file exists locally, but is not in the repository, and is not scheduled for addition.
None (default color)
The file hasn’t been changed.
Line status in the editor
To disable the colors, go to Settings/Preferences | Editor | General | Highlight modified lines in gutter and clear the necessary checkboxes.
#C3D6E8
Lines that have been modified since the last update.
#EDDCBC
Lines in which only whitespaces have been modified since the last update.
#C9DEC1
Lines that have been added since the last update.
#9F9F9F
Lines that have been removed since the last update.
#374752
Lines that have been modified since the last update.
#4C4638
Lines in which only whitespaces have been modified since the last update.
#384C38
Lines that have been added since the last update.
#656E76
Lines that have been removed since the last update.
#1AABFF
Lines that have been modified since the last update.
#666666
Lines in which only whitespaces have been modified since the last update.
#009924
Lines that have been added since the last update.
#FFA14F
Lines that have been removed since the last update.
Шпаргалка: Горячие (hotkeys) клавиши PhpStorm и PyCharm
Горячих клавиш в IDE PhpStorm и PyCharm гораздо больше, чем в приведенном ниже списке. Здесь я привел только те, которыми пользуюсь сам (* звездочкой выделил наиболее используемые мною горячие клавиши).
Шпаргалка будет обновляться, если начну использовать новые hotkeys.
Для настройки горячих клавиш или добавление собственных сочетаний клавиш перейдите File > Settings > Keymap.
Редактирование
*Ctrl + W — выделение текущего блока. Если нажимать W несколько раз, то будут выделяться родительские блоки по иерархии.
Ctrl + Shift + W — проделывает обратное действие от предыдущего
Ctrl + Y — удаляет строку
*Ctrl + D — дублирует строку
Ctrl + Shift + U — делает выделенный текст или заглавными, или строчными буквами
Ctrl + Delete — удаляет часть от курсора до конца слова
*Ctrl + Alt + L — форматирование кода соответствии с настройками code style.
*Ctrl + / — закомментировать/раскомментировать текущую строку.
Ctrl + Shift + / — закомментировать/раскомментировать выделенные строки кода.
Ctrl + Shift + J — к текущей строке присоединяет нижнюю.
Ctrl + [ или ] — перемещает курсор в начало или конец блока с кодом, в теле фукции, в теле цикла и т.д.
Ctrl + Shift + ] или [ — выделить код код до конца или до начала блока
*Tab — сделать отступ (табуляцию)
*SHIFT + Tab — убрать отступ
*Ctrl + Alt + Стрелка вверх — перемещает текущую строку вверх.
*Ctrl + Alt + Стрелка вниз — перемещает текущую строку вниз.
Ctrl + Shift + Стрелка вниз — перемещает текущий логический блок вниз
*Ctrl + Space — выводит возможные варианты автодополнения
Ctrl + курсор мыши над кодом — краткая информация
*Ctrl + клик по названию переменной или метода, или CTRL+B когда курсор установлен на названии, приведет туда, где метод или переменная определены.
*Ctrl + G — перейти к строке по номеру
*Alt + Клик левой кнопкой мышки — мультикурсор, если нужно одновременно несколько курсоров, кликаем мышкой в нужные места, куда нужно их добавить
*Ctrl + Alt + J — обрамление выделенного текста тегом (нужно выбрать первый пункт из всплывающего окошка)
F11 — быстро установить закладку
Shift + F11 — просмотр всех закладок
Поиск / замена
Двойной Shift — поиск по проекту
*Ctrl + F — поиск в текущем файле
*Ctrl + R — поиск и замена
*Ctrl+Shift+E — вызовет всплывающее окно, в котором показаны последние куски кода в разных файлах, с которыми вы работали
Ctrl + Shift + F — поиск в группе файлов (например в проекте или папке)
Ctrl + Shift + R — поиск и замена в группе файлов
Ctrl + N — найти в каком файле находится класс
*Ctrl + Shift + N — поиск файла по названию
Разное
Ctrl + Alt + S — быстрый доступ к настройкам
*Shift + F6 — переименование файла (выделите в блоке с файлами проекта нужный файл).