One, common small operations


1. Word choice

Generally, IDE uses option + arrow keys (win = CTRL + arrow keys) to move the cursor around the word, but since we use more camel name, the default will result in a camel head jump consisting of multiple words. Fortunately, AS can set this style.

The default effect

Effect after modification

Modify the steps

Turn on preferences such as image Settings

Note: If you still want to select the entire word after double-clicking on it, you need to set the following:

Open the File | Settings Settings

Select the Editor | General

Uncheck ‘Mouse’ | ‘Honor Camel Humps words Settings when selecting on double click’

2. Display the latest operations and modified files

For example, I open the main_activity.xml layout file and then close the page. Command + E will display the previous action file as follows.

So if you want to view a file that has been modified before, Command + Shift + E. Control + Tab can be used for quick interface switching.

shortcuts

  • The recent operation

  • Command + E** (mac)**

  • ctrl + E** (win)**

  • Recent changes

  • Command + Shift + E** (mac)**

  • ctrl + shift + enter** (win)**

3. File search

search Everywhere

The global lookup function file function in the project

Find class files

  • command + o (mac)
  • ctrl + n (win)

The default is to only look for class files in the project code, if you need to look for related classes in the SDK or class library. Press the shortcut key again, or check the following options to search for global class files

Find files

This level is broader than the one above. Include all files, such as XML, etc.

  • command + shift + o** (mac)**
  • ctrl + shift + n (win)

If you want to search for the class library or source code, please press the shortcut key again, or check the options given in the search class diagram.

4. Operation records

A lot of times when you’re going through the code structure, you’re going to follow through a lot of classes, and if you want to go back to the point of reversal. Then you have to remember this shortcut key.

  • Command + Option + Left\Right or Command + [, Command +]** (MAC)**
  • ctrl + alt + Left\Right**(win)**

5. Move rows

This one doesn’t need too much introduction, but the whole line moves up and down.

  • Option + Shift + Up/Down (MAC)
  • Alt + Shift + Arrow Up \ Arrow Down (win)

6. Look at the method call

Scenario: Find out where a method is called, or where an ID is referenced. Right-click on this method and select Find Left.

Shortcut:

  • option + F7** (mac)**
  • alt + F7 (win)

7. Follow up the method

Methods are always accompanied by referrals, and we always look inside methods for details. A common way to do this is to hold down Command and click on the method name.

You can also follow up within the method directly with Command + B at the cursor location.

  • Command + B (mac)
  • ctrl + alt + B (win)

8. Display method parameters

When we use a method, all the parameters are displayed at the beginning. But after a while it may not exist. At this point if you want to know what type the next argument is, or look at all the arguments, right

Shortcut:

  • command + P (mac)
  • ctrl + P (win)

If you also want to look at the documentation of the method, instead of following the source code, the F1 key will display the documentation.

9. Fast operation of lines

Delete lines quickly, actually using the cut function can Command + X

To copy lines quickly, use Command + Dmac, CTRL + Dwin

10. Multi-line operation

There may be times when we declare a series of related variables to be of type float, but what we really need is an int. At this point, you can make multiple choices for overall modification. The diagram below:

Hold down the Option key (Alt for Win) and select an area with the mouse. Then modify it accordingly.

You might think that the top has to be continuous. Would it satisfy your question if you could set multiple cursor points?

See below:

  • Option + Shift + Mouse Click (MAC)
  • Alt + Shift + mouse click **(win)**

You can add an edit cursor. Finally, if it is not needed then esc can close the extra cursor.

11. Fast completion

FindViewById () sometimes requires moving the mouse or cursor to the end to complete the semicolon. All of this can be done with shortcut keys. When you get used to it, it will be very convenient to use.

  • command + shift + enter**(mac)**
  • ctrl + shift + enter**(win)**

Implemented functions

  • Add braces to the method body
  • The addition of a semicolon at the end of a line
  • Automatic formatting and line change operations

12. Code hints

Code hints that can be called up anywhere.

Control + option + /(not default, MAC default is Control + space). The point here is that the code prompts are usually followed by the enter key. When you hit the Enter key. Will preserve the content after the cursor. Sometimes we don’t need it. At this point you can use the table key to select. It will delete the following input.

Shortcuts for Win: CTRL + space (Win also conflicts with the input method for most of the time. Please manually search the KeyMap TAB in the AS Settings for completion Basic and modify the shortcut keys manually.)

Quick variable generation

For example, in the body of a method, logi directly generates a template for logging output, but the TAG constant is not declared. Move the cursor over the TAG at this point. Use the shortcut key prompt to quickly generate.

  • option + enter**(mac)**
  • alt + enter**(win)**

Quick manipulation of variables

The image above uses the shortcut keys twice,

First: Jump to the declaration of the variable

  • command + B (mac)
  • ctrl + b (win)

Second: Jump to the definition of the variable type

  • command + shift + B** (mac)**
  • ctrl + shift + b** (win)**

Code folding

Collapses and expands code blocks.

  • Command + plus \ minus **(MAC)**
  • CTRL + + minus (win)

Preview method definitions

If you just want to get an overview of the method definition, you don’t need to jump through the source class of the method. You can preview it using Command + Y (CTRL + Shift + I for Win)

16. Paste board management

For copy and paste, we’re used to doing a single c+ V, so if you want to look at the copy that’s been overwritten before. AS also has copy-paste board to manage. Displays the latest copies.

  • command + shift + v** (mac)**
  • ctrl + shift + v** (win)**

17. Split Windows

Just right-click on the TAB. Select the split vertical and horizontal.

18. Variable naming style

Member variables should start with m. It usually starts with s for static members. You can set this style like this.

When you enter the name of a variable, you can automatically complete m or S. Meanwhile, when you enter Extra code, the generated code can be automatically refactored according to this rule.

19. Check the outline

When a class is large. You can open the outline screen using Command + F12(CTRL + F12 for Win). Displays the full list of methods and member variables.

Fuzzy search is also supported. To filter the display. You can quickly find the set of methods to search for.

20, bookmarks,

When browsing large code, or debugging. There may be times when you need to remember key code or methods. At this point you can use bookmarks. To document this critical code. Just click on the line you want to mark and press F3 to bring up a little check on the left. This means that a bookmark has been made.

You can also find the corresponding Bookmarks in the Favorites TAB

You can use the shortcut command + F3 (win = Shift + F11) to quickly bring up the bookmarks panel for subsequent operations.

Fast refactoring


1. Refactor entry

When a code fragment is ready for refactoring. You can open the refactoring portal by using Control + T (Win = CTRL + Alt + Shift + T). Or right-click and select Refactor to display the Refactor screen.

There’s a lot of convenience here. Commission method and so on.

2, surround With

When performing conditional wrapping on a piece of code, catch exceptions, loops, Runnable, etc. You can use a shortcut without having to manually generate conditions for copy-pasting code blocks

shortcuts

  • command + option + T(mac)
  • ctrl + alt + T(win)

3, Extract

You can use it often to extract a method.

Not only that, but you can also extract the same property from multiple controls in XML as style

Shortcut:

  • ctrl + alt + shift + T**(win)**

Isn’t that cool?

For one thing, you can extract not only Style but also Layout for XML

And in the code, you can extract variables, parameters, corridors.

Three, code module


AS already has a lot of code templates built into it, and you can swish through previously memorized code. Here’s a little bit

These code templates can be called up by shortcut keys

  • command + J**(mac)**
  • ctrl + J**(win)**

Iv. Code analysis


Google provides a number of code analysis tools, all of which are clustered in the Analyze column on the top menu bar.

Inspect Code & Code cleanup

Inspect Code lets the IDE analyze the entire project. Similar to Lint analysis, with general suggestions for changes, etc

The Code Cleanup feature makes automatic Code fixes.

2, Dependencies

Use several Dependencies options in Analyze. Project dependencies can be quickly analyzed.

3. Method call stack

For some methods, it is important to see where it is called and in what order. You can quickly find the method call stack by using Control + Option + H.

Five, breakpoint debugging


1. Fast debugging

Conditional breakpoint. Used mainly in the circulatory body. A for loop 10 times. Only wants to break on the eighth time.

Like a normal breakpoint, a breakpoint is declared first. Then right-click on the normal breakpoint. Fill in breakpoint conditions in the pop-up menu. As follows:

Enable controls whether to Enable or disable a breakpoint.

Temporary breakpoint. If you need a breakpoint that only executes once. The breakpoint is cancelled automatically after execution. The current line can then be used as a temporary breakpoint through a shortcut point.

  • command + option + shift + F8
  • ctrl + alt + shift + F8

For the length is not very long, debugging part of the post a very detailed explanation of the post

  • Android Studio code debugging daqo (blog.csdn.net/dd864140130…

6. Shortcut key lookup table


The lookup table lists the names of keyMap shortcuts. You can search for keymap directly on the AS Setting screen. You can add or modify shortcut keys based on their names.

In addition, there are:

  • 9 Tips for Android Studio Debug
  • Android Studio’s most comprehensive plugin collection to date

Android learning PDF+ architecture video + interview document + source notes

Thank you for taking the time to read this long wordy article

Here I also share a private, their own collection of organized Android learning PDF+ architecture video + interview document + source notes, and advanced architecture technology advanced brain map, Android development interview topic information, advanced architecture information to help you learn to promote advanced, but also save you on the Internet to search for information time to learn, You can also share it with your friends to learn together

If you need it, you can like + comment, follow me, and then add me VX: 15388039515 I will send to you (or follow wechat public number “Android Development house” reply [information] for free)