JavaRush /Java Blog /Random EN /How to create your own template (Live Template) in Intell...

How to create your own template (Live Template) in IntelliJ IDEA?

Published in the Random EN group
I came across this instruction in a telegram chat. Very happy with my new template! I understand that you need to type such lines of code yourself in order to know them by heart, but it’s very convenient to just type only two letters and press Enter. To generate the line "Scanner scanner = new Scanner(System.in);" along with automatic import of Scanner into the current file (similar to psvm), you need to do the following steps: 1) in the settings (File -> Settings or CTRL+ALT+S) go to the Editor -> Live Templates section. 2) expand the Java group (or leave it as is, then the template will fit in the user section). 3) click on the plus sign on the right and select Live Template. You will create a new Template. How to create your own template (Live Template) in IntelliJ IDEA?  - 1 4) in the Abbreviation field enter the required abbreviation (I have sssi configured), in the Description section enter a short description (I entered "New Scanner") 5) in the Template text field: enter java.util.Scanner scanner = new Scanner(System.in ); How to create your own template (Live Template) in IntelliJ IDEA?  - 2 6) at the bottom, where it says “No application contexts”, click the “Difine” button and select the Statement checkbox in the Java section. How to create your own template (Live Template) in IntelliJ IDEA?  - 3 7) click the Apply button. 8) now you can enter sssi in your program code, press Enter and a new scanner will appear and the cursor will move to a new line. If you want the cursor to be in a different location after the template is printed, use the $END$ construct to specify its location. For example, like this: java.util.Scanner scanner = new Scanner(System.in); $END$
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION