天天看点

更好的使用IntelliJ IDEA

一   快捷键的使用      

1.文本编辑

删除 ctr + y

复制 ctr + d

2.智能提示

提示 ctr + space

智能提示 ctr + shift + space

完成当前语句 ctr + shift + enter

建议提示为参数 ctr + alt + p

对代码重新排列格式 ctrl + alt + l

组织导入,对imports进行优化 ctrl + alt + o

3.位置定位

定位到下一个或上一个错误 f2 / shift + f2

定位文件头 ctr+g (定位到文件行数)

定位文件尾 ctr+g 

定位到代码块开始 ctr + [

定位到代码块结束 ctr + ]

回到最近的窗口 f12

回到之前的文件 alt + left

回到之后的文件 alt + right

定位到最后编辑位置 ctrl + shift + backspace

从tool window或其他window切换到文件编辑 esc

关闭最近打开的窗口 shift + esc

4.类、方法、文件定位

查找类 ctr + n

查找文件 ctrl + shift + n

符号定位 ctrl + alt + shift + n

查看文件结构 ctrl + f12

最近打开的文件 ctr + e

定位下一个方法 alt + down

定位上一个方法 alt + up

查看方法参数信息 ctr + p

查看方法、类的doc ctr + q

5.类、方法的结构查看、定位

跳到类或方法的声明 ctr + b

定位到类的父类、接口 ctr + u

查看类的继承结构 ctr + h

查看方法的继承结构 ctr + shift + h

查看类或方法被调用情况 ctr + alt +h 

原地参看类、方法的声明 ctrl + shift + i

6.运行与调试

ctrl + f9 make project (compile modifed and dependent)

ctrl + shift + f9 compile selected file, package or module

alt + shift + f10 select configuration and run

alt + shift + f9 select configuration and debug

shift + f10 run

shift + f9 debug

ctrl + shift + f10 run context configuration from editor

debugging

f8 step over

f7 step into

shift + f7 smart step into

shift + f8 step out

alt + f9 run to cursor

alt + f8 evaluate expression

f9 resume program

ctrl + f8 toggle breakpoint

ctrl + shift + f8 view breakpoints

二 idea和eclipse的区别   

idea 中 “new project”对应的是eclipse的“workspace”,而“new module”才是创建一个工程;

idea 不会自动编译和加载class,eclipse是自动的,

idea可以通过mode eclipse插件来实现自动加载和编辑class;

idea 编辑的文件是自动保存的,不能设置为手动保存。

三 idea常用设置

1.改变编辑文本字体大小

file -> settings -> editor colors & fonts -> font -> size

2.用*标识编辑过的文件

editor –> editor tabs

在idea中,你需要做以下设置, 这样被修改的文件会以*号标识出来,你可以及时保存相关的文件。"mark modifyied tabs with asterisk"

3.显示行号 

如何显示行号:settings->editor->appearance标签项,勾选show line numbers

4.自定义键盘快捷方式 

如果默认代码提示和补全快捷键跟输入法冲突,如何解决:settings->keymap

5.如何让光标不随意定位 

settings->editor中去掉allow placement of caret after end of line。

继续阅读