JetBrains系软件设置和使用技巧笔记

本文适用于 JetBrains 系软件,包含通用及单个软件的设置、使用技巧等,主要是在工作使用过程中遇到的问题及解决方式笔记。

1. 设置

1.1. 通用设置

关闭自动保存

菜单:Appearance & Behavior > System Settings > Synchronization

取消勾选:

  • Synchronize files on frame or editor tab activation
  • Save files on frame deactiation
  • Use "safe write"(save changes to a temporary file first)
打开修改文件未保存标识

菜单:Editor > General > Editor Tabs > Appearance

勾选:

  • Mark modified (*)
注释时使用缩进(而不直接添加到行首)
  1. 菜单:Editor > Code Style > Java > Wrapping and Braces > Keep when reformatting

    取消勾选

    • Comment at first column
  2. 菜单:Editor > Code Style > Java > Code Generation > Comment Code

    取消勾选

    • Line comment at first column
    • Block comment at first column

    如果需要在注释的开始位置后面追加一个空格(比如 // 这是注释),则勾选

    • Add a space at comment start
设置列宽提示线

菜单:Editor > Code Style > General

分别修改:

  • Hard wrap at
  • Visual guides
取消一些警告提示
  • 关闭拼写检查

    • Editor > Code Style > Inspections > Spelling

1.2. IDEA设置

取消一些警告提示
  • field injection is not recommended

    • Spring > Spring Core > Code > Autowiring for Bean Class 设置 SeverityWarning
  • could not autowire. No beans of 'SysLogininforMapper' type found.

    • Spring > Spring Core > Code > Field injection warning
  • 去除 MyBatis XML 文件中的黄、绿背景

    • Prefernces > Editor > Inspections > SQL > No data sources configure
    • Prefernces > Editor > Inspections > SQL > SQL dialect detection
    • Prefernces > Editor > Colors Scheme > General > Code > Injected language fragment > Background

1.3. WebStorm设置

不识别Vue项目的@路径别名
  1. 确保 vue.config.js 中有如下设置:

    'use strict'
    const path = require('path'
    function resolve(dir) {
    return path.join(__dirname, dir)
    }
    // ...
    module.exports = {
    //...
    configureWebpack: {
    //...
    // 主要是这部分
    resolve: {
    alias: {
    '@': resolve('src')
    }
    }
    }
    }
  2. 打开 WebStorm 的系统设置,搜索关键字 Webpack;

  3. 手动选择 Webpack 的配置文件,如:/Users/user1/www/demo-vue/node_modules/@vue/cli-service/webpack.config.js,其中:

    • 必须是绝对路径
    • node_modules/@vue/cli-service/webpack.config.js 在项目安装好之后才有。
  4. 保存,稍等一会儿。

2. 快捷键

2.1. 通用快捷键

# 在当前文件中查找字符
command + F

# 全局查找
command + shift + F

# 在当前文件中查找并替换
command + R

# 全局查找并替换
command + shift + R

# 最近打开过的文件
command + E

# 最近编辑过的文件
command + shift + E

# 根据类名快速打开文件
command + O

# 根据文件名快速打开文件
command + shift + O

# 根据方法名打开文件
command + alt + O

# 跳转到行和列,输入如:200:3 表示第 200 行,第3列
command + L

# 复制当前文件绝对路径
command + shift + C

# 从历史记录中粘贴
command + shift + V

# 快速查看、选择当前类结构
command + F12

# 跳到顶部面包屑导航条,使用方向键切换,回车下拉菜单
command + ⬆️

# 修改文件名,及所有引用它的地方
shift + F6

# 折叠整个类,展开方法,方法体还折叠
command + shift + -
command + +

2.2. IDEA快捷键

类相关(在一个类文件中)
# 快速修复
# 在类名、属性名、方法名上执行
alt + enter

# 可以选择快速生成当前类的构造方法、getter、setter、重写方法等
ctrl + enter

# 快速选择需要重写的方法
ctrl + o

# 去除未使用的引入包
ctrl + alt + o

3. 使用技巧

3.1. 通用

快速定位当前打开文件的位置
  • 方式一:单击侧边栏顶部的「准星」按钮(如果没有,则是开启了方式二);
  • 方式二:单击侧边栏顶部的「设置」按钮,勾选「Always Select Opened File」,则打开新文件时,左侧树形菜单自动定位目录位置。