android studio 代码快捷键

来源:互联网 发布:淘宝扣分12分会怎么样 编辑:程序博客网 时间:2024/04/30 10:25

android  studio 的代码快捷键,代码块


////输出打印
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 + SpaceBasic code completion (the name of any class,method or variable)基本的代码补全Ctrl + Shift + SpaceSmart code completion (filters the list of methodsand variables by expected type)智能代码补全Ctrl + Shift + EnterComplete statement补全当前语句Ctrl + PParameter info (within method call arguments)显示函数的参数信息Ctrl + QQuick documentation lookup快速文档查找Shift + F1External Doc外部文档Ctrl + mouse over code Brief Info简要信息显示Ctrl + F1Show descriptions of error or warning at caret显示错误或警告的说明Alt + InsertGenerate code... (Getters, Setters, Constructors,hashCode/equals, toString)生成(Getters, Setters, Constructors,hashCode/equals, toString)代码Ctrl + OOverride methods重写方法Ctrl + IImplement methods实现方法Ctrl + Alt + TSurround 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 + LReformat code重新格式化代码Ctrl + Alt + OOptimize imports优化导入的importCtrl + 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 + InsertCopy current line or selected block to clipboard复制当前行或者选中的代码段到剪贴板Ctrl + V or Shift + InsertPaste from clipboard从剪切板粘贴Ctrl + Shift + VPaste from recent buffers...粘贴最近复制的内容Ctrl + DDuplicate current line or selected block复制当前行或选中的代码Ctrl + YDelete line at caret删除行Ctrl + Shift + JSmart line join智能合并行Ctrl + EnterSmart line split智能分割行Shift + EnterStart new line新建一行Ctrl + Shift + UToggle case for word at caret or selected block将选中代码块转为小写Ctrl + Shift + ] / [ Select till code block end/start向前/向后选中代码段Ctrl + DeleteDelete to word end向后删除一个单词Ctrl + BackspaceDelete 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 ShiftSearch everywhere搜索任何地方的任何东西Ctrl + FFind查找F3        Find next查找下一个Shift + F3Find previous查找上一个Ctrl + R Replace替换Ctrl + Shift + FFind in path在路径中查找Ctrl + Shift + RReplace in path在路径中替换Ctrl + Shift + SSearch structurally (Ultimate Edition only)查找机构(商业版有效)Ctrl + Shift + MReplace structurally (Ultimate Edition only)替换结构(商业版有效)


Usage Search 查找使用

Alt + F7 / Ctrl + F7Find usages / Find usages in file查找使用Ctrl + Shift + F7Highlight usages in file在文件中高亮被使用处Ctrl + Alt + F7Show usages显示使用


Compile and Run 编译和运行

Ctrl + F9Make project (compile modifed and dependent)编译项目Ctrl + Shift + F9Compile selected file, package or module编译选中的文件、包或者木块Alt + Shift + F10Select configuration and run选择配置然后运行Alt + Shift + F9Select configuration and debug选择哦诶之然后调试Shift + F10Run运行Shift + F9Debug调试Ctrl + Shift + F10Run context configuration from editor


Debugging 调试

F8Step over跳过函数执行F7Step into单步执行Shift + F7Smart step into智能但不执行Shift + F8Step out跳出函数执行Alt + F9Run to cursor运行到光标处Alt + F8Evaluate expression

F9Resume program继续执行Ctrl + F8Toggle breakpoint切换断点Ctrl + Shift + F8View breakpoints查看断点


Navigation 导航

Ctrl + NGo to class查找/跳到类Ctrl + Shift + NGo to file查找文件Ctrl + Alt + Shift + NGo to symbol查找符号Alt + Right/LeftGo to next/previous editor tab

F12Go back to previous tool window

EscGo to editor (from tool window)

Shift + EscHide active or last active window

Ctrl + Shift + F4Close active run/messages/find/... tab

Ctrl + GGo to line

Ctrl + E Recent files popup    最近打开的文件Ctrl + Alt + Left/RightNavigate back/forward回到上一步/下一步编辑的地方Ctrl + Shift + BackspaceNavigate to last edit location回到最后编辑的地方Alt + F1Select current file or symbol in any view在任意视图中选中当前文件或者符号Ctrl + B or Ctrl + ClickGo to declaration到变量定义处Ctrl + Alt + BGo to implementation(s)到方法的实现处Ctrl + Shift + IOpen quick definition lookup打开定义快速查找Ctrl + Shift + BGo to type declaration跳转到方法定义处Ctrl + UGo to super-method/super-class跳转到父方法/父类Alt + Up/DownGo to previous/next method跳转到上一个/下一个方法Ctrl + ] / [Move to code block end/start跳到代码段的开始/结尾Ctrl + F12File structure popup弹出文件结构视图Ctrl + HType hierarchy类型的层次结构?Ctrl + Shift + HMethod hierarchy方法的层次结构?Ctrl + Alt + HCall hierarchy调用的层次结构(查找方法/符号的调用方)F2 / Shift + F2Next/previous highlighted error下一个(上一个)高亮的错误F4 / Ctrl + EnterEdit source / View source编辑/查看文件源码Alt + HomeShow navigation bar显示导航栏F11Toggle bookmark增加书签Ctrl + F11Toggle bookmark with mnemonic增加带符号的书签Ctrl + #[0-9]Go to numbered bookmark跳到标记数字的书签Shift + F11Show bookmarks显示书签


Refactoring 代码重构

F5Copy复制F6Move移动Alt + DeleteSafe Delete安全删除Shift + F6Rename重命名变量/方法名Ctrl + F6Change Signature改变Ctrl + Alt + NInline

Ctrl + Alt + MExtract Method

Ctrl + Alt + VExtract Variable

Ctrl + Alt + FExtract Field

Ctrl + Alt + CExtract Constant

Ctrl + Alt + PExtract Parameter


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

Ctrl + KCommit project to VCS

Ctrl + TUpdate project from VCS

Alt + Shift + CView recent changes查看最近更改的内容Alt + BackQuote (`)‘VCS’ quick popup


Live Templates 动态模板

Ctrl + Alt + JSurround with Live Template环绕的动态模板Ctrl + JInsert Live Template插入动态模板iterIteration according to Java SDK 1.5 style

inst Check object type with instanceof and downcast it

itcoIterate elements of java.util.Collection

itit Iterate elements of java.util.Iterator

itliIterate elements of java.util.List

psfpublic static final

thrthrow new


General 通用

Alt + #[0-9] Open corresponding tool window打开相应的工具窗口Ctrl + S Save all保存Ctrl + Alt + YSynchronize同步Ctrl + Shift + F12Toggle maximizing editor最大化编辑窗口Alt + Shift + FAdd to Favorites添加到FavoritesAlt + Shift + IInspect current file with current profile

Ctrl + BackQuote (`) Quick switch current scheme

Ctrl + Alt + SOpen Settings dialog打开设置窗口 Ctrl + Alt + Shift + S
Open Project Structure dialog打开项目结构窗口Ctrl + Shift + A Find Action查找快捷键Ctrl + TabSwitch 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



0 0