Intellij IDEA skills

Source: Internet
Author: User

Intellij IDEA skills
Code auto-completion (live templates) in IDEA

In IDEA, use the "shortcut key + TAB" to automatically complete the code.
For example, System. out. println (""); can be implemented by sout + TAB in IDEA.

Common Code auto-completion shortcut
Shortcut Key Description
Sout System. out. println ("");
Psvm Main Method
Write your own live templates

1. Open Live Templates and click + create live template or live template group. Here I create a live template named tag in the group named My Live Template.

2. IDEA provides related expressions for some operations. Click Edit variables to Edit the template variables and call related expressions in Expression.
For example, a NAME template variable ($NAME$Click Edit variables to view the variable. In Expression, className () is called to return the Class Name of the current class.


Reference URL for live templates expressions:https://www.jetbrains.com/idea/help/creating-and-editing-template-variables.html

3. Right-click the live template and select Change context to define the languages in which the live templates can be used.

4. Use a custom live template

Common shortcut keys
Shortcut Key Description
Alt + Ctrl + S Open Settings
Alt + Enter Quick Fix
Alt +/ Code auto-completion
Ctrl + Shift + u Case sensitivity Switch
Ctrl + Shift + I Display the Code definition according to the current context. For example, when the cursor is stopped on the method, the definition of the method is displayed in the popupview mode.
Ctrl + click Jump to source code
Shift + Shift Search all files
Ctrl + E Open the list of recently accessed files
Set Eclipse shortcut keys

Use a black topic

Default line number

Sets the file encoding to UTF-8 by default

Font settings

Open Font and click Save As to create a New Custom Font configuration. Setting the Size to 16 will be nice.

Use of quick code annotation

No shortcut key is set for the default Fix doc comment. Here I will set it to Alt + M

Press Alt + M on the method name, class name, and field name to automatically add the annotation template content.

Export the project to Eclipse


After the export is successful, the Eclipse project configuration file is automatically added to the project directory, and you can use Eclipse to open the project.

Custom files and code templates

1. Open File and Code Templates and click + to add your own template. For details about template writing, refer to the existing template.
Description document address:https://www.jetbrains.com/idea/help/creating-and-editing-file-templates.html

2. After the template is set, you can use the Custom template when New is used.

The template file is stored in the user directory.
-Windows:<your home directory>\.<product name><version number>\config\templates
-Linux:~/.<product name><version number>/config/templates
-OS X:~/Library/Preferences/<product name><version number>/templates

Associated api documentation

1. open the Project Structure (Ctrl + Shift + Alt + S). Here, you can associate the documents of the Module, Libraries, and SDK. Click + associate document. There are two +: one is to associate the local document, one is to associate online documents

2. After the association is successful, press Shift + F2 when the cursor stops at the class name to open the api doc for this class.

Unit Test

1. Create a test package to store related Test classes.

2. Create a class and write the test method.

public class ApkToolPlusTest {    public static final String TAG = ApkToolPlusTest.class.getSimpleName();    @Test    public void testJar2Smali() {        String jarPath = ApkToolPlusTest.class.getResource("trove4j.jar").getFile();        File jarFile = new File(jarPath);        ApkToolPlus.jar2smali(jarPath,jarFile.getParentFile().getPath()+"/smali");    }    @Test    public void testSignApk(){        String apkPath = ApkToolPlusTest.class.getResource("test_unsigned.apk").getFile();        KeystoreConfig config = new KeystoreConfig();        config.alias = "linchaolong";        config.aliasPassword = "linchaolong";        config.keystorePath = ApkToolPlusTest.class.getResource("debug.keystore").getFile();        config.keystorePassword = "linchaolong";        ApkToolPlus.signApk(apkPath, config);    }    @Test    public void testSystemProperties(){        Properties properties = System.getProperties();        properties.list(System.out);    }}

By default, the project does not import the jar of junit. You can import it by using alt + enter.

3. Run a test, such as testJar2Smali. You can right-click the testJar2Smali method and choose Run 'testjar2smali ()'

4. Run all the tests in the class, such as ApkToolPlusTest. You can right-click the class name and choose Run 'apktoolplustest'

5. run all the Tests in the package, such as all the Tests under the test package. You can right-click the package name and choose Run 'tests in test ', if you are running all the tests in the project, you can right-click the src folder or project and Run it.

Intellij idea reference manual address:https://www.jetbrains.com/idea/help/intellij-idea.html

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.