• This repository has been archived on 15/Dec/2022
  • Stars
    star
    200
  • Rank 188,329 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Atom snippets package
Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our official announcement

Snippets package

macOS Build Status Windows Build Status Dependency Status

Expand snippets matching the current prefix with tab in Atom.

To add your own snippets, select the Atom > Snippets... menu option if you're using macOS, or the File > Snippets... menu option if you're using Windows, or the Edit > Snippets... menu option if you are using Linux.

Snippet Format

Snippets files are stored in a package's snippets/ folder and also loaded from ~/.atom/snippets.cson. They can be either .json or .cson file types.

'.source.js':
  'console.log':
    'prefix': 'log'
    'body': 'console.log(${1:"crash"});$2'

The outermost keys are the selectors where these snippets should be active, prefixed with a period (.) (details below).

The next level of keys are the snippet names.

Under each snippet name is a prefix that should trigger the snippet and a body to insert when the snippet is triggered.

$ followed by a number are the tabs stops which can be cycled between by pressing tab once a snippet has been triggered.

The above example adds a log snippet to JavaScript files that would expand to.

console.log("crash");

The string "crash" would be initially selected and pressing tab again would place the cursor after the ;

Optional parameters

These parameters are meant to provide extra information about your snippet to autocomplete-plus.

  • leftLabel will add text to the left part of the autocomplete results box.
  • leftLabelHTML will overwrite what's in leftLabel and allow you to use a bit of CSS such as color.
  • rightLabelHTML. By default, in the right part of the results box you will see the name of the snippet. When using rightLabelHTML the name of the snippet will no longer be displayed, and you will be able to use a bit of CSS.
  • description will add text to a description box under the autocomplete results list.
  • descriptionMoreURL URL to the documentation of the snippet.

autocomplete-description

Example:

'.source.js':
  'console.log':
    'prefix': 'log'
    'body': 'console.log(${1:"crash"});$2'
    'description': 'Output data to the console'
    'rightLabelHTML': '<span style="color:#ff0">JS</span>'

Determining the correct scope for a snippet

The outmost key of a snippet is the "scope" that you want the descendent snippets to be available in. The key should be prefixed with a period (text.html.basic => .text.html.basic). You can find out the correct scope by opening the Settings (cmd-, on macOS) and selecting the corresponding Language [xxx] package, e.g. for Language Html:

Screenshot of Language Html settings

If it's difficult to determine the package handling the file type in question (for example, for .md-documents), you can also proceed as following. Put your cursor in a file in which you want the snippet to be available, open the Command Palette (cmd-shift-p), and run the Editor: Log Cursor Scope command. This will trigger a notification which will contain a list of scopes. The first scope that's listed is the scope for that language. Here are some examples: source.coffee, text.plain, text.html.basic.

Snippet syntax

This package supports a subset of the features of TextMate snippets, documented here.

The following features are not yet supported:

  • Variables
  • Interpolated shell code
  • Conditional insertions in transformations

Multi-line Snippet Body

You can also use multi-line syntax using """ for larger templates:

'.source.js':
  'if, else if, else':
    'prefix': 'ieie'
    'body': """
      if (${1:true}) {
        $2
      } else if (${3:false}) {
        $4
      } else {
        $5
      }
    """

Escaping Characters

Including a literal closing brace inside the text provided by a snippet's tab stop will close that tab stop early. To prevent that, escape the brace with two backslashes, like so:

'.source.js':
  'function':
    'prefix': 'funct'
    'body': """
      ${1:function () {
        statements;
      \\}
      this line is also included in the snippet tab;
      }
      """

Multiple snippets for the same scope

Snippets for the same scope must be placed within the same key. See this section of the Atom Flight Manual for more information.

More Repositories

1

atom

:atom: The hackable text editor
JavaScript
59,608
star
2

teletype

Share your workspace with team members and collaborate on code in real time in Atom
JavaScript
2,402
star
3

vim-mode

Next generation vim support for atom
CoffeeScript
1,722
star
4

node-keytar

Native Password Node Module
C++
1,364
star
5

apm

Atom Package Manager
CoffeeScript
1,263
star
6

markdown-preview

📝 Markdown preview in Atom
JavaScript
1,235
star
7

github

:octocat: Git and GitHub integration for Atom
JavaScript
1,085
star
8

autocomplete-plus

View and insert possible completions in the editor while typing
JavaScript
961
star
9

teletype-crdt

String-wise sequence CRDT powering peer-to-peer collaborative editing in Teletype for Atom.
JavaScript
749
star
10

flight-manual.atom.io

📖 Documentation for Atom, generated by nanoc, hosted by GitHub Pages
SCSS
632
star
11

tree-view

🌳 Explore and open project files in Atom
CoffeeScript
564
star
12

etch

Builds components using a simple and explicit API around virtual-dom
JavaScript
555
star
13

highlights

Syntax highlighter
CoffeeScript
531
star
14

one-dark-syntax

Atom One dark syntax theme
CSS
433
star
15

atom-languageclient

Language Server Protocol support for Atom (the basis of Atom-IDE)
TypeScript
388
star
16

ide-typescript

TypeScript and Javascript language support for Atom-IDE
JavaScript
367
star
17

fuzzaldrin

Fuzzy filtering and string scoring
CoffeeScript
317
star
18

node-spellchecker

SpellChecker Node Module
C++
294
star
19

fuzzy-finder

Find and open files quickly
JavaScript
277
star
20

settings-view

🔧 Edit Atom settings
CoffeeScript
269
star
21

ide-php

PHP language support for Atom-IDE
JavaScript
266
star
22

one-dark-ui

Atom One dark UI theme
CSS
262
star
23

find-and-replace

Find and replace in a single buffer and in the project
JavaScript
244
star
24

ide-java

Java language support for Atom-IDE
JavaScript
229
star
25

electron-link

A module to bundle your electron app into a single file that can be used for V8 snapshots.
JavaScript
214
star
26

teletype-client

Editor-agnostic library managing client interaction for peer-to-peer collaborative editing in Teletype for Atom
JavaScript
213
star
27

spell-check

Spell check Atom package
JavaScript
206
star
28

watcher

Atom Filesystem Watcher
C++
202
star
29

language-javascript

JavaScript language package for Atom
CoffeeScript
196
star
30

language-python

Python package for Atom
CoffeeScript
188
star
31

sort-lines

An Atom package to sort lines of text
JavaScript
174
star
32

git-utils

Git Node Module
JavaScript
167
star
33

symbols-view

Jump to symbols in Atom
JavaScript
164
star
34

welcome

Welcome editor thats shows on first run
JavaScript
158
star
35

atom.io

🌐 A place for feedback on the atom.io website and package API
157
star
36

superstring

Native core components for Atom
JavaScript
151
star
37

text-buffer

Atom's underlying text buffer
JavaScript
146
star
38

bracket-matcher

Jump to brackets
JavaScript
142
star
39

metrics

Help improve Atom by sending usage statistics, exceptions and deprecations to the team.
JavaScript
139
star
40

node-oniguruma

Oniguruma Node Module
JavaScript
121
star
41

language-php

PHP package for Atom
CoffeeScript
120
star
42

teletype-server

Server-side application that facilitates peer discovery for collaborative editing sessions in Teletype
JavaScript
118
star
43

command-palette

Command Palette in Atom
JavaScript
117
star
44

language-c

C support in Atom
CoffeeScript
117
star
45

styleguide

A package to exercise all the UI components.
JavaScript
115
star
46

fs-plus

node's fs module with some helpful additions
CoffeeScript
108
star
47

language-html

HTML package for Atom
CoffeeScript
108
star
48

tabs

Tabs in Atom
CoffeeScript
107
star
49

language-go

Go language package for Atom
CoffeeScript
106
star
50

atom-keymap

Atom's selector-based keymap system
CoffeeScript
103
star
51

atom-dark-ui

The default dark ui theme for Atom
CSS
103
star
52

git-diff

Diff markers in Atom's gutter
JavaScript
102
star
53

eon

Real-Time Conflict-Free Version Control System
102
star
54

language-ruby

Ruby package for Atom
Ruby
102
star
55

status-bar

Status bar for Atom
CoffeeScript
101
star
56

language-gfm

GitHub Flavored Markdown in Atom
CoffeeScript
101
star
57

event-kit

Simple library for implementing and consuming evented APIs
JavaScript
96
star
58

whitespace

Atom whitespace package
JavaScript
94
star
59

node-pathwatcher

Path Watcher Node Module
CoffeeScript
94
star
60

open-on-github

Atom package for opening files on GitHub.com
JavaScript
94
star
61

package-generator

Package to generate new packages
JavaScript
91
star
62

first-mate

TextMate helpers
JavaScript
89
star
63

season

CSON Node Module
CoffeeScript
85
star
64

ci

Build your Atom packages
PowerShell
83
star
65

language-todo

TODO highlighting package for Atom
CoffeeScript
81
star
66

toggle-quotes

An Atom package to toggle between single and double quotes
JavaScript
77
star
67

notifications

User notifications
CoffeeScript
75
star
68

solarized-dark-syntax

Atom syntax theme using the dark Solarized colors
CSS
74
star
69

one-light-ui

Atom One light UI theme
CSS
74
star
70

autocomplete-emojis

autocomplete+ emoji autocompletion
CoffeeScript
74
star
71

autocomplete-css

CSS property name and value completions
CoffeeScript
69
star
72

ascii-art

Convert selected text to ascii art banner
JavaScript
68
star
73

atom-ui

Atom's UI library
CSS
66
star
74

one-light-syntax

Atom One light syntax theme
CSS
64
star
75

autosave

Autosaves buffers when they lose focus
JavaScript
64
star
76

language-sass

Sass package for Atom
CoffeeScript
63
star
77

atom-space-pen-views

Atom SpacePen views that previously lived in core.
CoffeeScript
63
star
78

language-java

Java package for Atom
CoffeeScript
62
star
79

language-csharp

C# language support for Atom
Python
62
star
80

keyboard-layout

Node module to read and observe the current keyboard layout
C++
61
star
81

autocomplete-html

HTML tag and attribute completions
JavaScript
60
star
82

underscore-plus

Underscore with some extensions
CoffeeScript
60
star
83

language-css

CSS package for Atom
CoffeeScript
59
star
84

language-coffee-script

CoffeeScript support in Atom
CoffeeScript
58
star
85

atomdoc

Atom's documentation parser for JavaScript / CoffeeScript
JavaScript
58
star
86

atom-dark-syntax

Atom Dark Syntax theme
CSS
57
star
87

ide-csharp

C# language support for Atom-IDE
JavaScript
56
star
88

theorist

A reactive model toolkit for CoffeeScript
CoffeeScript
51
star
89

language-clojure

Clojure package for Atom
Clojure
49
star
90

bookmarks

Bookmark editor lines in Atom
JavaScript
49
star
91

language-ruby-on-rails

Ruby on Rails package for Atom
CoffeeScript
48
star
92

language-mustache

Mustache package for Atom
CoffeeScript
47
star
93

template-syntax

A template atom syntax theme to build from
Less
46
star
94

autocomplete-snippets

Adds snippets to autocomplete+ suggestions
JavaScript
46
star
95

keybinding-resolver

Shows what a keybinding resolves to
JavaScript
44
star
96

editor-stats

Graph your keyboard activity
CoffeeScript
44
star
97

image-view

View images in an Atom editor
JavaScript
44
star
98

base16-tomorrow-dark-theme

Base16 Theme for Atom
CSS
41
star
99

pr-changelog

Generate a PR changelog between two refs
JavaScript
40
star
100

scandal

Efficient directory scan + search utilities
CoffeeScript
40
star