我就针对一些常用的Android studio的live templates进行了一下汇总,
大家觉得有用的话就存下来吧,如果不熟悉的话经常去live pemplate进行查询有点麻烦,用熟悉了后就会好很多啦
Android studio 默认的是按Tab 自动生成代码块的,用户可以自己在setting-->Live Templates里面进行设置expand style

输出打印

Groovy(常规部分)----> 

serr --->System.err.println("example") 

souf --->printf "example" 

sout --->println "example" 

soutm --->System.out.println("MainActivity.onCreate");//当前类的当前方法名 

soutp --->System.out.println("savedInstanceState = [" + savedInstanceState + "]");//这个好,可以打印出当前方法的所有参数列表及其值 

soutv --->System.out.println("params",params);//即 你可以输出打印一个变量值 

//(常规的代码块儿) 

Iteractions--->//快速生成代码块儿 

fori --->for (int i = 0; i < ; i++) {} 

itar --->for (int i = 0; i < Array.length; i++) { int i1 = Array[i];}//遍历数组 

itco --->for (Iterator iterator = collection.iterator(); iterator.hasNext(); ) { 

Object next = iterator.next(); 

}//这个是遍历一个容器变量的,直接让容器返回一个iterator进行遍历 

iten --->while (枚举类.hasMoreElements()) { Object nextElement = 枚举类.nextElement(); }//enumeration 是一个枚举类接口来着。遍历枚举内容 

iter --->for (int i : FOCUSED_STATE_SET) {...}//遍历选中状态下的set 

itit --->while (iterator.hasNext()) { Object next = iterator.next(); }//获取到了迭代器对象后,对迭代器进行遍历操作 

itli --->for (int i = 0; i < list.size(); i++) { Object o = list.get(i); }//遍历list对象里面的内容 

ritar --->for (int i = Array.length - 1; i >= 0; i--) { int i1 = FOCUSED_STATE_SET[i]; }//倒叙遍历数组 

//其他的(综合) 

geti --->public static MainActivity getInstance() { return ; }//获取到当前的实例 的代码模板 

ifn --->if (某变量 == null) {....}//生成if null代码块儿 

inn --->if (某变量 != null) {....}//生成if not null代码块儿 

inst --->if ($EXPR$ instanceof $TYPE$) { $TYPE$ $VAR1$ = ($TYPE$)$EXPR$; $END$ }//判断某变量是不是某个类的实例对象 

lazy --->if (savedInstanceState == null) { savedInstanceState = new Bundle(); }//执行延迟初始化,就是对象直到用的时候才进行初始化操作 

mn --->var1 = Math.min(var2,var3);//得到比较两个变量值小的代码块 

mx --->var1 = Math.max(var2,var3);//得到比较两个变量值大的代码块 

psvm --->public static void main(String[] args){ 。。。。 }//生成一个main()函数的代码块 

toar --->something.toArray(new collection[collection.size()])//这个是生成一个代码块用于把collection的对象存储到一个数组里面去.实用! 

//普通的代码(修饰符部分的) 

psf --->public static final 
  

psfi --->public static final int 
  

psfs --->public static final String 
  

St --->String 
  
thr --->throw new



IDEA 快捷键


 


这是从IDEA官网下载的IDEA keymap Windows/Linux,中文我会慢慢补充上去。


因为AS是基于IDEA社区版开发的,所以快捷键都AS同样适用。


IntelliJ IDEA Default Keymap  
 
 
To find any action inside the IDE use

Find Action     Ctrl+Shift+A/ A    查找快捷键,action快捷入口的快捷键


Editing 编辑

Ctrl + Space

Basic code completion (the name of any class,method or variable)

基本的代码补全

Ctrl + Shift + Space

Smart code completion (filters the list of methodsand variables by expected type)

智能代码补全

Ctrl + Shift + Enter

Complete statement

补全当前语句

Ctrl + P

Parameter info (within method call arguments)

显示函数的参数信息

Ctrl + Q

Quick documentation lookup

快速文档查找

Shift + F1

External Doc

外部文档

Ctrl + mouse over code 

Brief Info

简要信息显示

Ctrl + F1

Show descriptions of error or warning at caret

显示错误或警告的说明

Alt + Insert

Generate code... (Getters, Setters, Constructors,hashCode/equals, toString)

生成(Getters, Setters, Constructors,hashCode/equals, toString)代码

Ctrl + O

Override methods

重写方法

Ctrl + I

Implement methods

实现方法

Ctrl + Alt + T

Surround with… (if..else, try..catch, for,synchronized, etc.)

用if..else, try..catch, for,synchronized等环绕代码块

Ctrl + / 

Comment/uncomment with line comment

注释/取消注释代码行

Ctrl + Shift + /

Comment/uncomment with block comment

注释/取消注释代码块

Ctrl + W 

Select successively increasing code blocks

依次选择更多的代码块

Ctrl + Shift + W    

Decrease current selection to previous state

依次减少选择的代码块

Alt + Q 

Context info


Alt + Enter 

Show intention actions and quick-fixes

显示意图行动和快速修复

Ctrl + Alt + L

Reformat code

重新格式化代码

Ctrl + Alt + O

Optimize imports

优化导入的import

Ctrl + Alt + I 

Auto-indent line(s)

自动缩进行

Tab / Shift + Tab 

Indent/unindent selected lines

缩进/取消缩进

/Ctrl + X or Shift + Delete 

Cut current line or selected block to clipboard

剪切当前行或者选中的代码段到剪切板

Ctrl + C or Ctrl + Insert

Copy current line or selected block to clipboard

复制当前行或者选中的代码段到剪贴板

Ctrl + V or Shift + Insert

Paste from clipboard

从剪切板粘贴

Ctrl + Shift + V

Paste from recent buffers...

粘贴最近复制的内容

Ctrl + D

Duplicate current line or selected block

复制当前行或选中的代码

Ctrl + Y

Delete line at caret

删除行

Ctrl + Shift + J

Smart line join

智能合并行

Ctrl + Enter

Smart line split

智能分割行

Shift + Enter

Start new line

新建一行

Ctrl + Shift + U

Toggle case for word at caret or selected block

将选中代码块转为小写

Ctrl + Shift + ] / [ 

Select till code block end/start

向前/向后选中代码段

Ctrl + Delete

Delete to word end

向后删除一个单词

Ctrl + Backspace

Delete to word start

向前删除一个单词

Ctrl + NumPad+/-

Expand/collapse code block

展开/折叠代码段

Ctrl + Shift + NumPad+

Expand all

全部展开

Ctrl + Shift + NumPad- 

Collapse all

全部折叠

Ctrl + F4 

Close active editor tab

关闭当前标签

Search/Replace 查找/替换

Double Shift

Search everywhere

搜索任何地方的任何东西

Ctrl + F

Find

查找

F3        

Find next

查找下一个

Shift + F3

Find previous

查找上一个

Ctrl + R 

Replace

替换

Ctrl + Shift + F

Find in path

在路径中查找

Ctrl + Shift + R

Replace in path

在路径中替换

Ctrl + Shift + S

Search structurally (Ultimate Edition only)

查找机构(商业版有效)

Ctrl + Shift + M

Replace structurally (Ultimate Edition only)

替换结构(商业版有效)


Usage Search 查找使用

Alt + F7 / Ctrl + F7

Find usages / Find usages in file

查找使用

Ctrl + Shift + F7

Highlight usages in file

在文件中高亮被使用处

Ctrl + Alt + F7

Show usages

显示使用


Compile and Run 编译和运行

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

查看断点


Navigation 导航

Ctrl + N

Go to class

查找/跳到类

Ctrl + Shift + N

Go to file

查找文件

Ctrl + Alt + Shift + N

Go to symbol

查找符号

Alt + Right/Left

Go to next/previous editor tab


F12

Go back to previous tool window


Esc

Go to editor (from tool window)


Shift + Esc

Hide active or last active window


Ctrl + Shift + F4

Close active run/messages/find/... tab


Ctrl + G

Go to line


Ctrl + E 

Recent files popup    

最近打开的文件

Ctrl + Alt + Left/Right

Navigate back/forward

回到上一步/下一步编辑的地方

Ctrl + Shift + Backspace

Navigate to last edit location

回到最后编辑的地方

Alt + F1

Select current file or symbol in any view

在任意视图中选中当前文件或者符号

Ctrl + B or Ctrl + Click

Go to declaration

到变量定义处

Ctrl + Alt + B

Go to implementation(s)

到方法的实现处

Ctrl + Shift + I

Open quick definition lookup

打开定义快速查找

Ctrl + Shift + B

Go to type declaration

跳转到方法定义处

Ctrl + U

Go to super-method/super-class

跳转到父方法/父类

Alt + Up/Down

Go to previous/next method

跳转到上一个/下一个方法

Ctrl + ] / [

Move to code block end/start

跳到代码段的开始/结尾

Ctrl + F12

File structure popup

弹出文件结构视图

Ctrl + H

Type hierarchy

类型的层次结构?

Ctrl + Shift + H

Method hierarchy

方法的层次结构?

Ctrl + Alt + H

Call hierarchy

调用的层次结构(查找方法/符号的调用方)

F2 / Shift + F2

Next/previous highlighted error

下一个(上一个)高亮的错误

F4 / Ctrl + Enter

Edit source / View source

编辑/查看文件源码

Alt + Home

Show navigation bar

显示导航栏

F11

Toggle bookmark

增加书签

Ctrl + F11

Toggle bookmark with mnemonic

增加带符号的书签

Ctrl + #[0-9]

Go to numbered bookmark

跳到标记数字的书签

Shift + F11

Show bookmarks

显示书签


Refactoring 代码重构

F5

Copy

复制

F6

Move

移动

Alt + Delete

Safe Delete

安全删除

Shift + F6

Rename

重命名变量/方法名

Ctrl + F6

Change Signature

改变

Ctrl + Alt + N

Inline


Ctrl + Alt + M

Extract Method


Ctrl + Alt + V

Extract Variable


Ctrl + Alt + F

Extract Field


Ctrl + Alt + C

Extract Constant


Ctrl + Alt + P

Extract Parameter



VCS/Local History 版本管理/本地历史

Ctrl + K

Commit project to VCS


Ctrl + T

Update project from VCS


Alt + Shift + C

View recent changes

查看最近更改的内容

Alt + BackQuote (`)

‘VCS’ quick popup



Live Templates 动态模板

Ctrl + Alt + J

Surround with Live Template

环绕的动态模板

Ctrl + J

Insert Live Template

插入动态模板

iter

Iteration according to Java SDK 1.5 style


inst 

Check object type with instanceof and downcast it


itco

Iterate elements of java.util.Collection


itit 

Iterate elements of java.util.Iterator


itli

Iterate elements of java.util.List


psf

public static final


thr

throw new



General 通用

Alt + #[0-9] 

Open corresponding tool window

打开相应的工具窗口

Ctrl + S 

Save all

保存

Ctrl + Alt + Y

Synchronize

同步

Ctrl + Shift + F12

Toggle maximizing editor

最大化编辑窗口

Alt + Shift + F

Add to Favorites

添加到Favorites

Alt + Shift + I

Inspect current file with current profile


Ctrl + BackQuote (`) 

Quick switch current scheme


Ctrl + Alt + S

Open Settings dialog

打开设置窗口

 Ctrl + Alt + Shift + S

Open Project Structure dialog

打开项目结构窗口

Ctrl + Shift + A 

Find Action

查找快捷键

Ctrl + Tab

Switch between tabs and tool window

在选项卡和工具窗口之间切换


与Ubuntu系统快捷键冲突的地方

Here’s a list of tweaks you need to make with default system key bindings so that they won’t interfere with IntelliJ IDEA actions (listed in brackets).

  • Disable the Shade window action, assigned to Ctrl + Alt + S (Settings dialog)
  • Change or disable the Lock Screen action, assigned to Ctrl + Alt + L (Reformat code)
  • Change or disable the Launch terminal action, assigned to Ctrl + Alt + T (Surround with)
  • Change or disable the Switch to workspace action, assigned to Сtrl + Alt + Arrows (Navigation)
  • Disable the Move window action, assigned to Alt + F7 (Find usages)
  • Change or disable the Resize window action, assigned to Alt + F8 (Evaluate expression