51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1271|回复: 0
打印 上一主题 下一主题

【转载】 Android Studio 使用技巧(2)

[复制链接]
  • TA的每日心情
    擦汗
    11 小时前
  • 签到天数: 1047 天

    连续签到: 5 天

    [LV.10]测试总司令

    跳转到指定楼层
    1#
    发表于 2016-4-28 13:44:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    About Keymaps

    Android Studio provides different keymaps (the mapping between shortcut keys and an action). You can see which keymap you are using in Settings->Keymap.

    It wouldn’t be practical to list the shortcuts for every keymap so the following will be used:

    • Windows: Default
    • Linux: Default
    • OSX: Mac OSX 10.5+
    Duplicate Linescmd+d ctrl+d

    Just as it says: it will copy the current line and paste it below without interfering with your clipboard. It can be pretty useful when it’s used with the move line shortcut!

    Expand/Shrink Selectionalt+up/down ctrl+w / ctrl+shift+w

    This will contextually expand the current selection. e.g. it will select the current variable, then the statement, then the method, etc.

    Surround withcmd+alt+t ctrl+alt+t

    This can be used to wrap a block of code in some structure. Usually an if statement, a loop, a try-catch or a runnable.

    If you have nothing selected, it will wrap the current line.

    Recentscmd+e ctrl+e

    Using this, you get a searchable list of the most recently consulted files!

    Live Templatescmd+j ctrl+j

    The live template is a way to quickly insert a snippet of code. The interesting thing with live templates is that they can be parameterized with sensible defaults and guide you through the parameters when you insert it.

    Additional Tip:

    • You don’t need to invoke the shortcut if you know the abbreviation. You only need to type it and complete using the Tab key.

    Move Methodscmd+alt+up/down ctrl+shift+up/down

    This is like the Move Line shortcut but applied to whole methods. It allows you to move a method below or above another one without copy-pasting.

    The real name of this action is Move Statement. Meaning that it moves any kind of statement. E.g. you can reorder fields and inner classes.

    Complete Statementcmd+shift+enter ctrl+shift+enter

    This will generate the missing code to complete a statement The usual use cases are:

    • Add a semicolon at the end of the line, even if you are not at the end of the line
    • Add the parentheses and curly braces after an if, while or for
    • Add the curly braces after a method declaration

    Additional Tip:

    • If a statement is already completed, it will go to the next line even if you are not at the last character of the current line.

    Last Edit Locationcmd+shift+backspace ctrl+shift+backspace

    This will make you navigate through the last changes you made. This is different from clicking the back arrow in the toolbar in that it makes you travel within your edition history and not your navigation history.

    Join Lines and Literalsctrl+shift+j ctrl+shift+j

    This is doing more than simulating the delete key at the end of the line! It will preserve formatting rules and it will also:

    • Merge two comment lines and remove the unused //
    • Merge multiline strings, removing the + signs and the double-quotes
    • Join fields and assignments

    Additional Tip:

    • If you select a string that spans multiple lines, it will merge it on a single one.

    Select Inalt+f1 alt+f1

    Takes the current file and asks you where to select it. The most useful shortcuts IMHO are to open in the project structure or in your file explorer. Note that each action is prefixed by a number or a letter, this is the shortcut to invoke it quickly.

    Usually, I’ll go Alt+F1 then Enter to open in the project view and Alt+F1+8 to reveal the file in Finder on the Mac.

    You can invoke this from a file or directly from the project view.

    Unwrap/Removecmd+shift+delete ctrl+shift+delete

    This will remove the surrounding code. It could be to remove an if statement, a while, a try/catch or even a runnable. This is exactly the opposite of the Surround With shortcut.

    本文出自Cym的博客(http://blog.csdn.net/cym492224103


    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-11-15 20:27 , Processed in 0.064436 second(s), 22 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表