常用工具的使用小技巧

0、GIT

0.1 git配置

如何永久保存https clone 下来的仓库账密

使用HTTPS方式,永久保存账号密码
git config --global credential.helper store

如何切换https为ssh

之前偷懒,在git clone的时候,使用了https下载下来repo,现在想换成ssh,如何操作呢?
方式有多种:
git remote set-url origin 【repo的ssh地址】

一、Chrome

  • ctrl 1~8 切换标签,9 最右边一个标签
  • Ctrl tab
  • Ctrl shift tab 都是来回切换标签
  • Ctrl J 显示已经下载的文件

二、sublime text

  • 批量删除空白行
    CTRL+H打开replace功能,勾选上左侧的regular expression,并填写
    find what栏 : \s+$ (正则表达式)
    replace with栏 : (这行留空)
    接着点replace all即可

三、IDEA

-1、Indexing cache 损坏 导致类中“飘红”(提示 类不存在)

表现就是:
明明是自己写的类,而且是在同一个 module 里,仅仅是包不一样,有的不飘红,有的飘红,十分诡异。
即使将整个项目都delete ,重新 clone 下来,重新 编译 ; 重新 maven reimport ,均不奏效

原因:
在IDEA为项目构建索引(indexing) 的时候,可能强制kill了IDEA进程,导致 index cache 损坏;即使重新git clone ,由于idea已有了坏掉的索引,还是会继续使用,问题不能解决。

解决:
使用 File >> invalidate caches/restart 功能,重新构建索引

(话说,这个问题以前也出现过,也解决过,但是不记录下来的话,过几天又忘了,又得花好多时间去定位。。)

0、如何使用Jar依赖,而不是使用模块依赖

这个问题有点少见,具体场景为:
多模块maven项目,不同模块之间可能也是相互依赖的,比如一个项目的依赖结构是这样的:
project A

    • module B
    • module C
    • module D
        • modlue C

B、C、D 都是 A的子模块,但是D 还是依赖了C。
默认情况下,IDEA 会读取 Maven POM,读取模块依赖关系,在本地形成依赖。但有时我们并不希望这样的依赖: C 打包时使用shade插件修改了包名,D Import的实际是 shade之后的包名,而不是当前的包名。 如果使用默认的模块依赖,就会引发编译不过。

解决方案:
右键–>Open Module Setting --> 打开这样的设置:

【注:这里的截图只是为了说明问题,并不是说 图中项目需要delete】。

其实,对于maven多模块项目来说,本质上这种做法是 修改了idea 中 maven setting: ignore files
在这里插入图片描述

1、如何解决Idea控制台乱码

https://blog.csdn.net/zfy1355/article/details/70157034

乱码分:
Main函数执行后 控制台乱码;

Tomcat输出乱码;

整个工程乱码。

2、Idea 使用技巧

各种骚操作

https://mp.weixin.qq.com/s/X_DKo4pAIa7TootqkJNXhA (推荐!!!)

自用必备的插件

  • find bug
  • gsonformat
  • inner builder
  • lombok
  • generateAllSetter
  • rainbow brackets
  • maven helper
  • generateSerialVersionId
  • restfulToolkit
  • material theme UI
  • mybatis log plugin (mybatis输出的日志还原为完整 SQL语句)
  • free mybatis
  • .ignore
  • jetty runner
  • String manipulation 字符串操作工具

idea的mode

  • code review时,将idea代码投影到幕上,如何使得代码编辑区域最大呢
    可以开启 View 模式中的presentation mode 演示 code review

同时还可以开启:

  • distraction free mode 潜心写代码,没有干扰
  • full screen
    在这里插入图片描述

如何收藏自己喜欢的代码或者包

阅读源码,有时“看上”了某个类,或者一整个包,想要收藏,方便自己迅速查找回看,可以使用idea的收藏功能: add to favorites

  • 打开侧边栏 【快捷键alt 2 】
  • 点击加入 favorite list ; 或者 直接按 【shift + alt + F】快速开启
  • 删除 :直接按delete
    在这里插入图片描述

学习资源

https://github.com/judasn/IntelliJ-IDEA-Tutorial/

断点

  • 调试时 如果是个带 return 的方法,则可以 force return
  • F9 resume programe 恢复程序
  • Alt+F10 show execution point 显示执行断点
  • F8 Step Over 相当于eclipse的f6 跳到下一步
  • F7 Step Into 相当于eclipse的f5就是 进入到代码
  • Alt+shift+F7 Force Step Into 这个是强制进入代码
  • Shift+F8 Step Out 相当于eclipse的f8跳到下一个断点,也相当于eclipse的f7跳出函数
  • Atl+F9 Run To Cursor 运行到光标处
  • ctrl+shift+F9 debug运行java类
  • ctrl+shift+F10 正常运行java类
  • alt+F8 debug时选中查看值

快捷键(黄色的尤其推荐)

  • F2 --> 在editor 中的高亮错误代码提示之间跳转

  • Ctrl shift I --> 可以在当前类中再弹出一个窗口出来(十分方便,省得跳来跳去了)

  • Ctrl F12 --> show class members 类成员快速显示 (这就省得 跳到侧边栏的 Structure ,再去查看了)

  • Ctrl shift 句号 --> 表示折叠某个特定的代码块

  • Ctrl 加减号 --> 全部折叠、打开方法等代码块

  • alt F7 查看当前方法、接口等的useages(会在终端里显示 usages)

  • ctrl H --> 显示类的层级关系

  • ctrl alt H : 显示方法(注意是方法的调用链)
    在我看来,这个快捷键,可以显示出方法的调用链,因此是阅读源码的最不可少的了。

  • ctrl alt U :显示类的调用关系图(注意是类的调用链)

  • ctrl P 显示接口参数

  • ctrl O 显示类方法

  • Ctrl+E 显示最近修改的代码

  • use Alt F12 to enter into Terminal Console! --> 进入控制台

  • use alt F2 to run the brower from the edit area --> 从编辑区进入浏览器

  • By pressing Alt+Shift+F10 you can access the Run/Debug dropdown on the main toolbar, without the need to use your mouse.

  • It is possible to rename CSS selectors directly from HTML. Position the caret at the selector to be renamed and press Shift+F6 (Refactor | Rename). --> Shift+F6 重构 代码

  • If you don’t want to commit some of your changes to the repository, you can set them aside for a while, by moving to a separate changelist, or by putting them to a shelf. Select such file in the Local tab of the Changes tool window, and on the context menu choose Move to Another Changelist, or Shelve Changes。 --> 假如不想提交所有改动的代码,可以将其放入一个单列的 changelist 里

  • To quickly find a menu command or toolbar action, you do not need to look through the menus. Just press Ctrl+Shift+A (Help | Find Action on the main menu) and start typing the name of the action. Choose the desired action from the suggestion list. --> 显示 工具栏

  • To quickly find and run an inspection, press Ctrl+Alt+Shift+I and start typing the name of the inspection or its group. Choose the desired inspection from the suggestion list and then specify the desired scope.

  • Ctrl+Shift+F12 : Hide All Tool Windows (隐藏所有工具窗口) 这个操作的快捷键。

  • ctrl alt o 优化包 import

  • To view all exit points of a method, place the caret at one of them, e.g. the return statement, and press Ctrl+Shift+F7: (所有的return语句等 方法退出点)

  • Ctrl+Click (on Windows) :显示文件所在的真实路径
    这样可以快速定位到文件真实路径

  • alt + 7 显示类中方法的结构

  • Ctrl+Alt+T (Code | Surround With) 抽出来代码块给try catch

  • Ctrl+Alt+B.显示一个接口方法的被override后的方法

  • Ctrl+Alt+V : 抽取一段代码作为局部变量

  • Alt+Shift+Up/Down,上/下移一行

  • Ctrl Alt shift c : 获取一个方法的含包名的名字

and more…

最常用快捷键
1.Ctrl+E,可以显示最近编辑的文件列表
2.Shift+Click可以关闭文件
3.Ctrl+[或]可以跳到大括号的开头结尾
4.Ctrl+Shift+Backspace可以跳转到上次编辑的地方
5.Ctrl+F12,可以显示当前文件的结构
6.Ctrl+F7可以查询当前元素在当前文件中的引用,然后按F3可以选择
7.Ctrl+N,可以快速打开类
8.Ctrl+Shift+N,可以快速打开文件
9.Alt+Q可以看到当前方法的声明
10.Ctrl+W可以选择单词继而语句继而行继而函数
11.Alt+F1可以将正在编辑的元素在各个面板中定位
12.Ctrl+P,可以显示参数信息
13.Ctrl+Shift+Insert可以选择剪贴板内容并插入
14.Alt+Insert可以生成构造器/Getter/Setter等
15.Ctrl+Alt+V 可以引入变量。例如把括号内的SQL赋成一个变量
16.Ctrl+Alt+T可以把代码包在一块内,例如try/catch
17.Alt+Up and Alt+Down可在方法间快速移动

下面的不是很有用
18.在一些地方按Alt+Enter可以得到一些Intention Action,例如将”==”改为”equals()”
19.Ctrl+Shift+Alt+N可以快速打开符号
20.Ctrl+Shift+Space在很多时候都能够给出Smart提示
21.Alt+F3可以快速寻找
22.Ctrl+/和Ctrl+Shift+/可以注释代码
23.Ctrl+Alt+B可以跳转到抽象方法的实现
24.Ctrl+O可以选择父类的方法进行重写
25.Ctrl+Q可以看JavaDoc
26.Ctrl+Alt+Space是类名自动完成
27.快速打开类/文件/符号时,可以使用通配符,也可以使用缩写
28.Live Templates! Ctrl+J
29.Ctrl+Shift+F7可以高亮当前元素在当前文件中的使用
30.Ctrl+Alt+Up /Ctrl+Alt+Down可以快速跳转搜索结果
31.Ctrl+Shift+J可以整合两行
32.Alt+F8是计算变量值

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值