Creating snippets for Atom text editor

in #atom8 years ago

Atom logo

One thing that most people struggle with at first, when coming from IDE's such as Eclipse, NetBeans, IntelliJ and so on, is to get familiarised with the editor behaviour and Atom makes it so easy and stress-free to customise.

Without further do, let's create our first snippet for the Java language.

Go to Atom > Open Your Snippets

# Java Snippets
'.source.java':
  'System.out.println()':
    'prefix': 'sout'
    'body': 'System.out.println($1);$2'

The code above will generate the snippet once the user types-in sout.

.source.js - will simply tell the editor that this snippet belongs to .java files.

System.out.println() - is the name of our snippet, name it whatever you want.

'prefix': 'sout' - is the actual trigger, once the user types-in sout and press tab, it will auto-complete with the body of the snippet and will place the cursor to the first position $1.

'body': 'System.out.println($1);$2' - this is the code snippet you want to auto-complete, notice that $1 indicates the first position and $2 indicates the second, which is the same as double tab.

There you go, now you can port over all sort of snippets based on your previous IDE.

To make your Atom even more IDE alike you can install Atom Linter.

Atom linter preview

Once you have linter installed you can add support for the languages you wish to work with, like Java, Python, PHP etc. to see all languages go to language specific linters

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 60935.93
ETH 2645.60
USDT 1.00
SBD 2.56