javavisual-studio-code

Create a shortcut for system.out.println in visual studio code


I am using visual studio code IDE for my Java project and I want to create a shortcut for:

System.out.println();

That is if I write sysout or something like that it will automatically changed to System.out.println(); with cursor inside parenthesis.

Is there any way it can be achieved in VScode?


Solution

  • There is no need to define the snippet yourself. You can install https://marketplace.visualstudio.com/items?itemName=redhat.java, which contains the predefined snippet for your case (and more than that), here are some screenshot:

    sysout:

    enter image description here

    syserr:

    enter image description here

    and even systrace:

    enter image description here

    If you want to developing your Java application in VS Code, you can also install https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack, which provides debugging, testing, project managing capabilities to you.