Jetbrains 软件使用总结:idea、pycharm、goland

发布时间: 更新时间: 总字数:1470 阅读时间:3m 作者: IP上海 分享 网址
专栏文章
  1. 十大Intellij IDEA快捷键

Jetbrains 出了一系列的编程工具,包括:ideapycharmgoland等。本文介绍这些工具的使用主题设置内存优化插件安装快捷键,以及使用中常见问题等。

主题

下载

color-themes

导入主题

在IDEA中导入该主题,具体如下:

file –> import setttings –> 选中 1 中下载的主题jar文件 –> 一路确认 –> 重启

设置主题

settings –> editor –> colors & fonts –> general

清除配置文件

rm -rf ~/Library/Preferences/Idea****
rm -rf ~/Library/Caches/Idea****
rm -rf ~/Library/Logs/Idea****

PS:以 idea 为例,其他的软件和这个类似。

自动配置License

File -> New Projects Setup -> Settings/Preferences for New Projects -> Editor -> Copyright -> Copyright Profiles -> + ->
  • name: Copyright
  • content:
Copyright $originalComment.match("Copyright \(c\) (\d+)", 1, "-", "$today.year")$today.year xiexianbin.cn
All Rights Reserved.

  Licensed under the Apache License, Version 2.0 (the "License"); you may
  not use this file except in compliance with the License. You may obtain
  a copy of the License at
       http://www.apache.org/licenses/LICENSE-2.0
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  License for the specific language governing permissions and limitations
  under the License.
  • 选择 Editor -> Copyright,Default project copyrithg 为 Copyright,Scope 为 Project Files,Copyrith 为 Copyright

  • 选择 Editor -> Copyright -> Formatting Python 定制格式

  • 然后新创建的文件有自动有 Copyright 了

  • 其他文件添加:command + , -> Action -> Copyright

方法注释

Settings -> Tools -> Python Integrated Tools -> Docstrings -> Docstring format

优化

设置内存限制

help -> Edit Custom VM Options...

内容如下:

-Xms1024m
-Xmx2048m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:MaxMetaspaceSize=4096m

注:需重启。也可以更新 pycharm.vmoptions,重启生效。

显示内存使用

File -> settings -> Apperance & Behavior -> Appearance 勾选 Show memory indicator

在 idea 的右下角,可以看到。

设置主题

黑色太难看了:

File -> Settings... (Ctrl + Alt + s) -> Appearance & Behavior -> Appearance -> UI Options -> Theme -> IntelliJ

调整字体

File -> Settings... (Ctrl + Alt + s) -> Editor -> Font -> Size

显示行号和空格符

File -> Settings -> Editor -> General -> Appearance
  • Show line numbers
  • Show whitespaces
    • Leading
    • Inner
    • Trailing

Python PEP8 检测

Editor -> Inspections

配置

PEP8 coding style violation
PEP8 naming convention violation

Severity: Error

返回光标上次的位置

Views -> Appearance -> Toolbar,通过菜单栏中的 <--> 跳转

快捷键:

option + command + ->option + command + <-

Python 插件安装

查看IDEA版本

在 help/about 中查看IDEA版本

IntelliJ IDEA 2017.2.6
Build #IU-172.4574.11, built on November 14, 2017
Licensed to lan yu
Subscription is active until October 14, 2018
JRE: 1.8.0_152-release-915-b12 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

下载插件

http://plugins.jetbrains.com/plugin/631 中下载对应的插件,172.4574.11 对应的是 python-143.116.zip

安装插件

  • windows下解压到 IDEA 的 plugins 目录,ideaIU-2017.2.6.win\plugins\python

  • 在IDEA中选择插件的安装方式为

File -> settings -> plugins -> Inatall plugin from disk...

注意:

  • 此时选择 ideaIU-2017.2.6.win\plugins\python\lib\python.jar 安装,然后重启 IDEA

  • 创建Python项目,配置Python SDK

File/New Project/Python,设置Project SDKE:\Python\python.exe,创建Python项目

  • Python项目中new一个Directory或者是Package,并写一个简单测试文件,测试Python环境是否配置成功。

PyCharm 中调试 Django management 命令

在调试配置菜单上创建步骤如下:

  • 单击 Edit Configurations...
  • 点击加号并选择 Django server
  • 在填写 Name,清除 HostPort,检查 Custom run command 并输入的命令的名称(py 文件的名称)
  • 将命令行参数输入到 Additional options中,不是附加在运行命令中
  • 点击确定
  • 设置一个断点,从 Run / Debug Configuration 菜单中选择你的新配置并点击 Debug 按钮

扩展:

常见问题

CPU 占用较高问题

问题原因:

打开包含nodejs项目时,包含node_modules目录会导致 idea 一直 scanning files to index 会占用大量CPU资源

  • 方法一:

可以直接修改 <project_name>.iml 文件跳过该目录文件的扫描,如下excludeFolder配置:

<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <excludeFolder url="file://$MODULE_DIR$/frontend/node_modules" />
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
</module>

PS: .gitingore中也应该有对应目录

  • 方法二:

File - Settings - Project: yourprojectname - Project Structure - Right click on folder and press "Excluded"

  • 方法二:

File - Settings - Editor - File Types - Ingore file and types 中填加 node_modules

调整快捷键

Preferences -> keymap -> 设置具体的快捷键,这里的快捷键,是安装菜单顺序排列的,可以按照菜单选择

goland gofmt 格式化问题

通过 File to Watch 在文件变化是调用 gofmt 对文件进行格式化

Preferences -> Tools -> File Watchers 添加 gofmt 模板

  • Program: gofmt
  • Arguments: -l -w -s $FilePath$
  • Output paths to refresh: $FilePath$
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数