IDEA usage skills (transfer)

In the process of using InelliJ IDEA , through finding information and some own exploration, I found that there are many tips worth mentioning in this IDE that many Java programmers like. If you can skillfully apply them to the actual development process, I believe It will save you a lot of development time, and there will be a little sense of achievement that comes with it :) Try it!
1. When writing code, use Alt-Insert (Code|Generate…) to create getter and setter methods for any field in the class.
2. Right-click on the breakpoint marker (in the left column of the text) to activate the quick-check menu, where you can quickly set the enable/disable breakpoint or condition its properties.
3. A special variable in the CodeCompletion property is that activating Ctrl-Alt-Space can complete class names in or not in the current file. The import flag is automatically created if the class is not imported.
4. Use the Ctrl-Shift-V shortcut to insert the most recently used clipboard content selection into the text. When using, the system will pop up a dialog box containing clipping content, from which you can select the part you want to paste.
5. Use the CodeCompletion (code completion) property to quickly complete various statements in the code by typing the first few letters of a class name and then using Ctrl-Space to complete the full name. If there are multiple options, they are listed in the cheat list.
6. Use Ctrl-/ and Ctrl-Shift-/ to comment/uncomment lines and blocks of code.
-/Comment/uncomment the current line or select block of code with a single-line comment marker ("//..."). Ctrl-Shift-/ , on the other hand, encloses the selected block with block comment markers (""). To uncomment a block of code just press Ctrl-Shift-/ anywhere in the block .
7. Press Alt-Q (View|Context Info) to view the current method declaration without moving the code. Press twice in succession to display the currently edited class name.
8. Use Refactor|Copy Class ... to create a "copy" of a selected class. This is useful, for example, when you want to create a class that is mostly identical to an existing class. 9. Ctrl-D
in the editor can copy the selected block or the current line without the selected block. 10. The function of Ctrl-W (select word) in the editor is to first select the word at the caret, and then select the extension area of ​​the source code. For example, choose a method name, then the expression that calls the method, then the entire statement, then the containing block, and so on. 11. If you don't want the "bright ball" icon indicating event details to be displayed in the editor, you can set the bright ball attached to the event text to non by pressing the Alt-Enter key combination to open the list of all events and clicking it with the mouse. Active status. This way there won't be a bright ball to indicate a special event later, but you can still use it with the Alt-Enter shortcut.



12. When using CodeCompletion, you can use the comma (.) character, comma (,) semicolon (;), space and other characters to enter the currently highlighted part in the popup list. The selected name is automatically entered into the editor along with the characters entered.
13. Use the Escape key in any tool window to move the focus to the editor.
Shift-Escape not only moves the focus to the editor but also hides the current (or last active) tool window.
The F12 key moves the focus from the editor to the most recently used tool window.
14. An easy way to see the value of any expression while debugging a program is to select the text in the editor (you can do this more efficiently by pressing Ctrl-W a few times) and then press Alt-F8.
15. To open the browser for the Java documentation of the class or method used at the editor's caret, press Shift-F1 (External JavaDoc in the right-click menu).
To use this feature, you need to add the path to the browser, set it in the "General" option (Options | IDE Settings), and add the created Java document to the project (File | Project Properties).
16. With the Ctrl-F12 (View | File Structure Popup) keys you can quickly navigate through the currently edited file.
At this point it will display a list of members of the current class. Highlight an element to navigate and press Enter or F4 . To easily navigate to an entry in the list, just type its name.
17. Put the cursor on the marker or its checkpoint in the code and press Alt-F7(Find Usages... in the right-click menu) will quickly find the location of a class, method or variable used in the entire project.
18. Press Ctrl-N (Go to | Class…) and then type the name of the class to quickly open any class in the editor. Select the class from the drop-down list that appears.
In the same way you can open non-Java files in a project by using Ctrl-Shift-N (Go to | File…).
19. To navigate the declarations of classes, methods, or variables used in some places in the code, place the cursor on the view item and press Ctrl-B . You can also navigate to the declaration by pressing the Ctrl key and clicking the mouse button on the viewing point.
20. Put the cursor on the view point and press Ctrl-Alt-B to navigate to the implementation code of an abstract method.
21. To see the inheritance hierarchy of a selected class, press Ctrl-H (Browse Type Hierarchy). You can also activate the inheritance relationship view in the editor to view the inheritance relationship of the currently edited class.
22. Use Ctrl-Shift-F7 (Search | Highlight Usages in File) to quickly highlight the usage of a variable in the current file. Press Escape to clear the highlight.
23. Use Alt-F3 (Search | Incremental Search) to implement the quick search function in the editor.
在“Search for:”提示工具里输入字符,使用箭头键朝前和朝后搜索。按Escape退出。
24、按Ctrl-J组合键来执行一些你记不起来的Live Template缩写。比如,键“it”然后按Ctrl-J看看有什么发生。
25、Introduce Variable整合帮助你简化代码中复杂的声明。举个例子,在下面的代码片断里,在代码中选择一个表达式:
然后按Ctrl-Alt-V(Refactor | Introduce Variable)就会出现下面的结果:
26、Ctrl-Shift-J快捷键把两行合成一行并把不必要的空格去掉以匹配你的代码格式。
27、Ctrl-Shift-Backspace(Go to | Last Edit Location)让你调转到代码中所做改变的最后一个地方。
多按几次Ctrl-Shift-Backspace查看更深的修改历史。
28、用Tools | Reformat Code…根据你的代码样式参考(查看Options | IDE Setting | Code Style)格式化代码。
Use Tools | Optimize Imports... to automatically "optimize" imports (clean out useless imports, etc.) based on settings (see Options | IDE Setting | Code Style | Imports).
29. Use IDEA's Live Templates | Live Templates lets you create a lot of typical code in the blink of an eye. For example, type in a method and
press Tab key to see what happens.
Use the Tab key to move through the different template fields. See Options | Live Templates for more details.
30. To view the local history of modifications in a file, activate Local VCS | Show History… in the context menu. Maybe you can navigate the different file versions, see how they differ and roll back to any previous version.
The history of modifications in a directory can also be viewed using the same right-click menu entry. With this feature you won't lose any code.
31. If you want to understand the purpose of each item in the main menu, it may be helpful for you to move the mouse pointer over the menu items and display some brief descriptions of them in the status bar at the bottom of the application frame.
32. To display the separators between methods in the editor, open Options | IDE Settings | Editor and select the "Show method separators" checkbox.
33. Use the Alt-Up and Alt-Down keys to quickly move between different methods in the editor.
34. Use F2/Shift-F2 to jump between highlighted syntax errors.
useCtrl-Alt-Down/Ctrl-Alt-Up shortcuts can jump between compiler error messages or search results.
35. By pressing Ctrl-O (Code | Override Methods…) you can easily override the base class methods.
To implement the methods of the interface of the current class implements (or of the abstract base class), use Ctrl-I (Code | Implement Methods…).
36. If the cursor is placed between the parentheses of a method call, pressing Ctrl-P displays a list of available parameters.
37. To quickly view the Java documentation for the class or method used at the editor's caret, press Ctrl-Q (in the Show Quick JavaDoc in the popup menu).
38. Like Ctrl-Q (Show Quick JavaDoc shows concise Java documentation), Ctrl-P (Show Parameter Info shows parameter information), Ctrl-B (Go to Declaration jumps to declaration), Shift-F1 (External JavaDoc external Java documentation ) ) and some other shortcuts can be used not only in the editor, but also in the code completion right-click list.
39. Ctrl-E(View | Recent Files) pops up a right-click list of recently accessed files. Select the file and press Enter to open it.
40. In IDEA you can easily rename your classes, methods and variables and automatically correct them everywhere you use them.
To try it out, place the editor caret on any variable name and press Shift-F6 (Refactor | Rename…). Type the new name to be displayed in the dialog box and press Enter . You will browse to all places where this variable is used and press the "Do Refactor" button to end the rename operation.
41. To quickly
select , press Alt-F1 (View | Select in…).
42. When instantiating an object of a known type after the "new" character, you may use SmartType code to accomplish this feature. For example, type and press C**trl-Shift-Space**:
3. By using SmartType code completion, it is also very easy to create the entire anonymous implementation of the interface in IDEA. For example, for some listeners, you can type
Component component;
component.addMouseListener(
new
);
then press Ctrl-Shift-Space again to see what happens.
44. SmartType code completion is also helpful when you need to set the value of an expression of a known type. For example, type

String s = (<caret is here> 

Press Ctrl-Shift-Space again and see what comes up.
45. Quick lookup function is provided in all views: just type characters in the tree to quickly locate an item.
46. ​​When you want to use a code snippet to catch exceptions, select the snippet in the editor, press Ctrl-Alt-T (Code | Surround with...) and select "try/catch". It automatically generates catch blocks for all exceptions thrown in the snippet. In the Options | File Templates | Code tab you can also customize the templates for generating capture blocks.
Other structures can be surrounded by other items in the list.

47. When using code completion, use the Tab key to enter the highlighted part in the pop-up list.
Unlike the Enter key to accept input, the selected name overwrites the rest of the name to the right of the caret. This is especially useful when substituting one method or variable name for another.
48. The code completion feature will show you a suggested name when declaring a variable. For example, start typing "private FileOutputStream" and press Ctrl-Space

intellij idea tutorial

First of all, I want to say one thing, in IntelliJ IDEA "new Project" is equivalent to the "workspace" of our eclipse, and "new Module" is to create a project, which is a point to pay attention to.

在IDEA里面“new Project”,它会自动建一个工程(如果你一直按标准程序创建的),名字和你这个工作空间是一样的(first),如果你在这个空间里多建一个自己的 工程(second),那么seconde的工程的根目录会和first的web,src,out在平级目录中。显得很乱,虽然这样也是正确的,所以,我 强烈建议还是一个空间中只有一个工程(也是IDEA标准建法)。

IDEA建好的工程中,你是看不到输出目录的,只能看到src,web,而WEB-INF下的classes,lib,都没有。但是你在磁盘中打开,你就能发现out中,有3个目录exploded,production,test,

exploded: It is the output directory of your real web. IDEA has given you an alias called xxxxweb. Everyone is familiar with it and has everything.
production: the output of all .class files is in this
test: test class and resource file output directory.

**IDEA建工程的技巧**

1. The first is new project—>create project from scratch—>get a name—>next—>next—>check the web application checkbox, of course you need to check other things—–>finish
this is basically everyone span

2. Now you have a standard directory, configure tomcat, there is a downward arrow on it, click Edit Configurations, --> the "+" sign in the upper left corner --> TomcatServer --> local --> give a name -- >In Application Server-->configure-->select the tomcat path-->kill the check box of start browser-->kill the check box in the lower left corner, select fix-->apply->ok in the lower right

3. Go to your disk, open your new project, find E:\test\web\WEB-INF (assuming the project is called test), and manually create two folders in WEB-INF, named classes and lib.

4. Go back to idea, right-click on your space-->Module Settings--select test in the second vertical column-->Paths-->Use module compile output path-->output path select the one you just built in the disk classes.

5. It is still the second vertical column --> web--> select Java EE Bulid Settings on the right--> Create web module exploded directory path on the right to select the web path of your program (E:\test\web)
The following Exclude from The check box of module content needs to be eliminated a little bit, if you don't kill your web, it will be gone in idea.

6. Add lib, or the second column --> web -- --> select Dependencies --> add --> Module Library
--> Attach Jar Directories --> directory to select the lib that was manually built before.
In the process of using InelliJ IDEA, through finding information and some own exploration, I found that there are many tips worth mentioning in this IDE that many Java programmers like. If you can skillfully apply them to the actual development process, I believe It will save you a lot of development time, and there will be a little sense of achievement that comes with it :) Try it!
1. When writing code, use Alt-Insert (Code|Generate...) to create getter and setter methods for any field in the class.
2. Right-click on the breakpoint marker (in the left column of the text) to activate the quick-check menu, where you can quickly set the enable/disable breakpoint or condition its properties.
3. A special variable in the CodeCompletion property is that activating Ctrl-Alt-Space can complete class names in or not in the current file. The import flag is automatically created if the class is not imported.
4. Use the Ctrl-Shift-V shortcut to insert the most recently used clipboard content selection into the text. When using, the system will pop up a dialog box containing clipping content, from which you can select the part you want to paste.
5. Use the CodeCompletion (code completion) property to quickly complete various statements in the code by typing the first few letters of a class name and then using Ctrl-Space to complete the full name. If there are multiple options, they are listed in the cheat list.
6. Use Ctrl-/ and Ctrl-Shift-/ to comment/uncomment lines and blocks of code.
-/Comment/uncomment the current line or select block of code with a single-line comment marker ("//..."). Ctrl-Shift-/, on the other hand, encloses the selected block with block comment markers (""). To uncomment a block of code just press Ctrl-Shift-/ anywhere in the block.
7. Press Alt-Q (View|Context Info) to view the declaration of the current method without moving the code. Press twice in succession to display the currently edited class name.
8. Use Refactor|Copy Class... to create a "copy" of the selected class. This is useful, for example, when you want to create a class that is mostly identical to an existing class.
9. Ctrl-D in the editor can copy the selected block or the current line without the selected block.
10. The function of Ctrl-W (select word) in the editor is to first select the word at the caret, and then select the extension area of ​​the source code. For example, choose a method name, then the expression that calls the method, then the entire statement, then the containing block, and so on.
11. If you don't want the "bright ball" icon indicating event details to be displayed in the editor, you can set the bright ball attached to the event text to non by pressing the Alt-Enter key combination to open the list of all events and clicking it with the mouse. Active status.
This way there won't be a bright ball to indicate a special event later, but you can still use it with the Alt-Enter shortcut.
12. When using CodeCompletion, you can use the comma (.) character, comma (,) semicolon (;), space and other characters to enter the currently highlighted part in the popup list. The selected name is automatically entered into the editor along with the characters entered.
13. Use the Escape key in any tool window to move the focus to the editor.
Shift-Escape not only moves the focus to the editor but also hides the current (or last active) tool window.
The F12 key moves the focus from the editor to the most recently used tool window.
14. An easy way to see the value of any expression while debugging a program is to select the text in the editor (you can do this more efficiently by pressing Ctrl-W a few times) and then press Alt-F8.
15. To open the browser for the Java documentation of the class or method used at the editor's caret, press Shift-F1 (External JavaDoc in the right-click menu).
To use this feature, you need to add the path to the browser, set it in the "General" option (Options | IDE Settings), and add the created Java document to the project (File | Project Properties).
16. With the Ctrl-F12 (View | File Structure Popup) keys you can quickly navigate in the currently edited file.
At this point it will display a list of members of the current class. Highlight an element to navigate and press Enter or F4. To easily navigate to an entry in the list, just type its name.
17. Put the cursor on the marker or its checkpoint in the code and press Alt-F7 (Find Usages... in the right-click menu) to quickly find a class, method or variable used in the entire project s position.
18. Press Ctrl-N (Go to | Class…) and then type the name of the class to quickly open any class in the editor. Select the class from the drop-down list that appears.
In the same way you can open non-Java files in a project by using Ctrl-Shift-N (Go to | File…).
19. To navigate the declarations of classes, methods, or variables used in some places in the code, place the cursor on the view item and press Ctrl-B. You can also navigate to the declaration by pressing the Ctrl key and clicking the mouse button on the viewing point.
20. Put the cursor on the view point and press Ctrl-Alt-B to navigate to the implementation code of an abstract method.
21. To see the inheritance hierarchy of a selected class, press Ctrl-H (Browse Type Hierarchy). You can also activate the inheritance relationship view in the editor to view the inheritance relationship of the currently edited class.
22. Use Ctrl-Shift-F7 (Search | Highlight Usages in File) to quickly highlight the usage of a variable in the current file. Press Escape to clear the highlight.
23. Use Alt-F3 (Search | Incremental Search) to implement quick search function in the editor.
Enter characters in the "Search for:" tooltip and use the arrow keys to search forward and backward. Press Escape to exit.
24. Press Ctrl-J to execute some Live Template abbreviations you can't remember. For example, key "it" and then press Ctrl-J to see what happens.
25. Introduce Variable integration helps you simplify complex declarations in your code. For example, in the following code snippet, select an expression in the code:
Then press Ctrl-Alt-V (Refactor | Introduce Variable) and the following result will appear:
26. Ctrl-Shift-J shortcut Lines are combined into one line and unnecessary spaces are stripped to match your code format.
27. Ctrl-Shift-Backspace (Go to | Last Edit Location) lets you go to the last place where changes were made in the code.
Press Ctrl-Shift-Backspace several times to see a deeper revision history.
28. Use Tools | Reformat Code... to format the code according to your code style reference (see Options | IDE Setting | Code Style).
Use Tools | Optimize Imports... to automatically "optimize" imports (clean out useless imports, etc.) based on settings (see Options | IDE Setting | Code Style | Imports).
29. Use IDEA's Live Templates | Live Templates lets you create a lot of typical code in the blink of an eye. For example, type in a method and
press Tab key to see what happens.
Use the Tab key to move through the different template fields. See Options | Live Templates for more details.
30. To view the local history of modifications in a file, activate Local VCS | Show History… in the context menu. Maybe you can navigate the different file versions, see how they differ and roll back to any previous version.
The history of modifications in a directory can also be viewed using the same right-click menu entry. With this feature you won't lose any code.
31. If you want to understand the purpose of each item in the main menu, it may be helpful for you to move the mouse pointer over the menu items and display some brief descriptions of them in the status bar at the bottom of the application frame.
32. To display the separators between methods in the editor, open Options | IDE Settings | Editor and select the "Show method separators" checkbox.
33. Use the Alt-Up and Alt-Down keys to quickly move between different methods in the editor.
34. Use F2/Shift-F2 to jump between highlighted syntax errors.
Use the Ctrl-Alt-Down/Ctrl-Alt-Up shortcuts to jump between compiler error messages or search results.
35. You can easily override basic class methods by pressing Ctrl-O (Code | Override Methods…).
To implement the methods of the interface of the current class implements (or of the abstract base class), use Ctrl-I (Code | Implement Methods…).
36. If the cursor is placed between the parentheses of a method call, pressing Ctrl-P displays a list of available parameters.
37. To quickly view the Java documentation for the class or method used at the editor's caret, press Ctrl-Q (in the Show Quick JavaDoc in the popup menu).
38. Like Ctrl-Q (Show Quick JavaDoc to display concise Java documentation), Ctrl-P (Show Parameter Info to display parameter information), Ctrl-B (Go to Declaration), Shift-F1 (External JavaDoc external Java documentation) ) and some other shortcuts can be used not only in the editor, but also in the code completion right-click list.
39. Ctrl-E (View | Recent Files) pops up a right-click list of recently accessed files. Select the file and press Enter to open it.
40. In IDEA you can easily rename your classes, methods and variables and automatically correct them everywhere you use them.
To try it out, place the editor caret on any variable name and press Shift-F6 (Refactor | Rename…). Type the new name you want to display in the dialog box and press Enter. You will browse to all places where this variable is used and press the "Do Refactor" button to end the rename operation.
41. To be quick in any view (Project View, Structure View or other view)
Select the currently edited part (class, file, method or field) and press Alt-F1 (View | Select in...).
42. When instantiating an object of a known type after the "new" character, you may use SmartType code to accomplish this feature. For example, type and press Ctrl-Shift-Space:
3. By using SmartType code completion, it is also very easy to create the entire anonymous implementation of the interface in IDEA. For example, for some listeners, you can type

  Component component;
  component.addMouseListener(
    new <caret is here> 
  );

Then press Ctrl-Shift-Space again to see what happens.
44. SmartType code completion is also helpful when you need to set the value of an expression of a known type. For example, type
String s = (
and press Ctrl-Shift-Space to see what comes up.
45. Quick lookup is available in all views: just type a character in the tree to quickly navigate to an entry.
46 , When you want to use a code snippet to catch exceptions, select the snippet in the editor, press Ctrl-Alt-T (Code | Surround with...) and select "try/catch". It will automatically generate the code snippet that throws the exception Catch blocks for all exceptions. In the Options | File Templates | Code tab you can also customize the templates for generating catch blocks.
Other structures can be surrounded by other items in the list.

47. When using code completion, use the Tab key to enter the highlighted part in the pop-up list.
Unlike the Enter key to accept input, the selected name overwrites the rest of the name to the right of the caret. This is especially useful when substituting one method or variable name for another.
48. The code completion feature will show you a suggested name when declaring a variable. For example, start typing "private FileOutputStream" and press Ctrl-Space

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325806617&siteId=291194637