• Packages
  • Themes
  • Documentation
  • Blog
  • Discussions

Chapter 1: Getting Started

  • Why Atom?
  • Installing Atom
  • Atom Basics
  • Summary

Chapter 2: Using Atom

  • Atom Packages
  • Moving in Atom
  • Atom Selections
  • Editing and Deleting Text
  • Find and Replace
  • Snippets
  • Autocomplete
  • Folding
  • Panes
  • Pending Pane Items
  • Grammar
  • Version Control in Atom
  • GitHub package
  • Writing in Atom
  • Basic Customization
  • Summary

Chapter 3: Hacking Atom

  • Tools of the Trade
  • The Init File
  • Package: Word Count
  • Package: Modifying Text
  • Package: Active Editor Info
  • Creating a Theme
  • Creating a Grammar
  • Creating a Legacy TextMate Grammar
  • Publishing
  • Iconography
  • Debugging
  • Writing specs
  • Handling URIs
  • Cross-Platform Compatibility
  • Converting from TextMate
  • Hacking on Atom Core
  • Contributing to Official Atom Packages
  • Creating a Fork of a Core Package in atom/atom
  • Maintaining a Fork of a Core Package in atom/atom
  • Summary

Chapter 4: Behind Atom

  • Configuration API
  • Keymaps In-Depth
  • Scoped Settings, Scopes and Scope Descriptors
  • Serialization in Atom
  • Developing Node Modules
  • Interacting With Other Packages Via Services
  • Maintaining Your Packages
  • How Atom Uses Chromium Snapshots
  • Summary

Reference: API

  • AtomEnvironment
  • BufferedNodeProcess
  • BufferedProcess
  • Clipboard
  • Color
  • CommandRegistry
  • CompositeDisposable
  • Config
  • ContextMenuManager
  • Cursor
  • Decoration
  • DeserializerManager
  • Directory
  • DisplayMarker
  • DisplayMarkerLayer
  • Disposable
  • Dock
  • Emitter
  • File
  • GitRepository
  • Grammar
  • GrammarRegistry
  • Gutter
  • HistoryManager
  • KeymapManager
  • LayerDecoration
  • MarkerLayer
  • MenuManager
  • Notification
  • NotificationManager
  • Package
  • PackageManager
  • Pane
  • Panel
  • PathWatcher
  • Point
  • Project
  • Range
  • ScopeDescriptor
  • Selection
  • StyleManager
  • Task
  • TextBuffer
  • TextEditor
  • ThemeManager
  • TooltipManager
  • ViewRegistry
  • Workspace
  • WorkspaceCenter

Appendix A: Resources

  • Glossary

Appendix B: FAQ

  • Is Atom open source?
  • What does Atom cost?
  • What platforms does Atom run on?
  • How can I contribute to Atom?
  • Why does Atom collect usage data?
  • Atom in the cloud?
  • What's the difference between an IDE and an editor?
  • How can I tell if subpixel antialiasing is working?
  • Why is Atom deleting trailing whitespace? Why is there a newline at the end of the file?
  • What does Safe Mode do?
  • I have a question about a specific Atom community package. Where is the best place to ask it?
  • I’m using an international keyboard and keys that use AltGr or Ctrl+Alt aren’t working
  • I’m having a problem with Julia! What do I do?
  • I’m getting an error about a “self-signed certificate”. What do I do?
  • I’m having a problem with PlatformIO! What do I do?
  • How do I make Atom recognize a file with extension X as language Y?
  • How do I make the Welcome screen stop showing up?
  • How do I preview web page changes automatically?
  • How do I accept input from my program or script when using the script package?
  • I am unable to update to the latest version of Atom on macOS. How do I fix this?
  • I’m trying to change my syntax colors from styles.less, but it isn’t working!
  • How do I build or execute code I've written in Atom?
  • How do I uninstall Atom on macOS?
  • macOS Mojave font rendering change
  • Why does macOS say that Atom wants to access my calendar, contacts, photos, etc.?
  • How do I turn on line wrap?
  • The menu bar disappeared, how do I get it back?
  • How do I use a newline in the result of find and replace?
  • What is this line on the right in the editor view?

Appendix C: Shadow DOM

  • Removing Shadow DOM styles

Appendix D: Upgrading to 1.0 APIs

  • Upgrading Your Package
  • Upgrading Your UI Theme Or Package Selectors
  • Upgrading Your Syntax Theme

Appendix E: Atom server-side APIs

  • Atom package server API
  • Atom update server API

  • mac
  • windows
  • linux

Config Essential

Used to access all of Atom’s configuration details.

An instance of this class is always available as the atom.config global.

Getting and setting config settings.

# Note that with no value set, ::get returns the setting's default value.
atom.config.get('my-package.myKey') # -> 'defaultValue'

atom.config.set('my-package.myKey', 'value')
atom.config.get('my-package.myKey') # -> 'value'

You may want to watch for changes. Use ::observe to catch changes to the setting.

atom.config.set('my-package.myKey', 'value')
atom.config.observe 'my-package.myKey', (newValue) ->
  # `observe` calls immediately and every time the value is changed
  console.log 'My configuration changed:', newValue

If you want a notification only when the value changes, use ::onDidChange.

atom.config.onDidChange 'my-package.myKey', ({newValue, oldValue}) ->
  console.log 'My configuration changed:', newValue, oldValue

Value Coercion

Config settings each have a type specified by way of a schema. For example we might want an integer setting that only allows integers greater than 0:

# When no value has been set, `::get` returns the setting's default value
atom.config.get('my-package.anInt') # -> 12

# The string will be coerced to the integer 123
atom.config.set('my-package.anInt', '123')
atom.config.get('my-package.anInt') # -> 123

# The string will be coerced to an integer, but it must be greater than 0, so is set to 1
atom.config.set('my-package.anInt', '-20')
atom.config.get('my-package.anInt') # -> 1

Defining settings for your package

Define a schema under a config key in your package main.

module.exports =
  # Your config schema
  config:
    someInt:
      type: 'integer'
      default: 23
      minimum: 1

  activate: (state) -> # ...
  # ...

See package docs for more info.

Config Schemas

We use json schema which allows you to define your value’s default, the type it should be, etc. A simple example:

# We want to provide an `enableThing`, and a `thingVolume`
config:
  enableThing:
    type: 'boolean'
    default: false
  thingVolume:
    type: 'integer'
    default: 5
    minimum: 1
    maximum: 11

The type keyword allows for type coercion and validation. If a thingVolume is set to a string '10', it will be coerced into an integer.

atom.config.set('my-package.thingVolume', '10')
atom.config.get('my-package.thingVolume') # -> 10

# It respects the min / max
atom.config.set('my-package.thingVolume', '400')
atom.config.get('my-package.thingVolume') # -> 11

# If it cannot be coerced, the value will not be set
atom.config.set('my-package.thingVolume', 'cats')
atom.config.get('my-package.thingVolume') # -> 11

Supported Types

The type keyword can be a string with any one of the following. You can also chain them by specifying multiple in an an array. For example

config:
  someSetting:
    type: ['boolean', 'integer']
    default: 5

# Then
atom.config.set('my-package.someSetting', 'true')
atom.config.get('my-package.someSetting') # -> true

atom.config.set('my-package.someSetting', '12')
atom.config.get('my-package.someSetting') # -> 12

string

Values must be a string.

config:
  someSetting:
    type: 'string'
    default: 'hello'

integer

Values will be coerced into integer. Supports the (optional) minimum and maximum keys.

  config:
    someSetting:
      type: 'integer'
      default: 5
      minimum: 1
      maximum: 11

number

Values will be coerced into a number, including real numbers. Supports the (optional) minimum and maximum keys.

config:
  someSetting:
    type: 'number'
    default: 5.3
    minimum: 1.5
    maximum: 11.5

boolean

Values will be coerced into a Boolean. 'true' and 'false' will be coerced into a boolean. Numbers, arrays, objects, and anything else will not be coerced.

config:
  someSetting:
    type: 'boolean'
    default: false

array

Value must be an Array. The types of the values can be specified by a subschema in the items key.

config:
  someSetting:
    type: 'array'
    default: [1, 2, 3]
    items:
      type: 'integer'
      minimum: 1.5
      maximum: 11.5

color

Values will be coerced into a Color with red, green, blue, and alpha properties that all have numeric values. red, green, blue will be in the range 0 to 255 and value will be in the range 0 to 1. Values can be any valid CSS color format such as #abc, #abcdef, white, rgb(50, 100, 150), and rgba(25, 75, 125, .75).

config:
  someSetting:
    type: 'color'
    default: 'white'

object / Grouping other types

A config setting with the type object allows grouping a set of config settings. The group will be visually separated and has its own group headline. The sub options must be listed under a properties key.

config:
  someSetting:
    type: 'object'
    properties:
      myChildIntOption:
        type: 'integer'
        minimum: 1.5
        maximum: 11.5

Other Supported Keys

enum

All types support an enum key, which lets you specify all the values the setting can take. enum may be an array of allowed values (of the specified type), or an array of objects with value and description properties, where the value is an allowed value, and the description is a descriptive string used in the settings view.

In this example, the setting must be one of the 4 integers:

config:
  someSetting:
    type: 'integer'
    default: 4
    enum: [2, 4, 6, 8]

In this example, the setting must be either ‘foo’ or ‘bar’, which are presented using the provided descriptions in the settings pane:

config:
  someSetting:
    type: 'string'
    default: 'foo'
    enum: [
      {value: 'foo', description: 'Foo mode. You want this.'}
      {value: 'bar', description: 'Bar mode. Nobody wants that!'}
    ]

If you only have a few elements, you can display your enum as a list of radio buttons in the settings view rather than a select list. To do so, specify radio: true as a sibling property to the enum array.

config:
  someSetting:
    type: 'string'
    default: 'foo'
    enum: [
      {value: 'foo', description: 'Foo mode. You want this.'}
      {value: 'bar', description: 'Bar mode. Nobody wants that!'}
    ]
    radio: true

Usage:

atom.config.set('my-package.someSetting', '2')
atom.config.get('my-package.someSetting') # -> 2

# will not set values outside of the enum values
atom.config.set('my-package.someSetting', '3')
atom.config.get('my-package.someSetting') # -> 2

# If it cannot be coerced, the value will not be set
atom.config.set('my-package.someSetting', '4')
atom.config.get('my-package.someSetting') # -> 4

title and description

The settings view will use the title and description keys to display your config setting in a readable way. By default the settings view humanizes your config key, so someSetting becomes Some Setting. In some cases, this is confusing for users, and a more descriptive title is useful.

Descriptions will be displayed below the title in the settings view.

For a group of config settings the humanized key or the title and the description are used for the group headline.

config:
  someSetting:
    title: 'Setting Magnitude'
    description: 'This will affect the blah and the other blah'
    type: 'integer'
    default: 4

Note: You should strive to be so clear in your naming of the setting that you do not need to specify a title or description!

Descriptions allow a subset of Markdown formatting. Specifically, you may use the following in configuration setting descriptions:

  • bold - **bold**
  • italics - *italics*
  • links - [links](https://atom.io)
  • code spans - `code spans`
  • line breaks - line breaks<br/>
  • strikethrough - ~~strikethrough~~

order

The settings view orders your settings alphabetically. You can override this ordering with the order key.

config:
  zSetting:
    type: 'integer'
    default: 4
    order: 1
  aSetting:
    type: 'integer'
    default: 4
    order: 2

Manipulating values outside your configuration schema

It is possible to manipulate(get, set, observe etc) values that do not appear in your configuration schema. For example, if the config schema of the package ‘some-package’ is

config:
someSetting:
  type: 'boolean'
  default: false

You can still do the following

let otherSetting  = atom.config.get('some-package.otherSetting')
atom.config.set('some-package.stillAnotherSetting', otherSetting * 5)

In other words, if a function asks for a key-path, that path doesn’t have to be described in the config schema for the package or any package. However, as highlighted in the best practices section, you are advised against doing the above.

Best practices

  • Don’t depend on (or write to) configuration keys outside of your keypath.

Config Subscription

::observe(keyPath, options, callback)

Add a listener for changes to a given key path. This is different than ::onDidChange in that it will immediately call your callback with the current value of the config entry.

Examples

You might want to be notified when the themes change. We’ll watch core.themes for changes

atom.config.observe 'core.themes', (value) ->
  # do stuff with value
Argument Description

keyPath

String name of the key to observe

options

optional

Object

scope

optional

ScopeDescriptor describing a path from the root of the syntax tree to a token. Get one by calling {editor.getLastCursor().getScopeDescriptor()}. See ::get for examples. See the scopes docs for more information.

callback

Function to call when the value of the key changes.

value

the new value of the key

Return values

Returns a Disposable with the following keys on which you can call .dispose() to unsubscribe.

::onDidChange(keyPath, options, callback)

Add a listener for changes to a given key path. If keyPath is not specified, your callback will be called on changes to any key.

Argument Description

keyPath

optional

String name of the key to observe. Must be specified if scopeDescriptor is specified.

options

optional

Object

scope

optional

ScopeDescriptor describing a path from the root of the syntax tree to a token. Get one by calling {editor.getLastCursor().getScopeDescriptor()}. See ::get for examples. See the scopes docs for more information.

callback

Function to call when the value of the key changes.

event

Object

newValue

the new value of the key

oldValue

the prior value of the key.

Return values

Returns a Disposable with the following keys on which you can call .dispose() to unsubscribe.

Managing Settings

::get(keyPath, options)

Retrieves the setting for the given key.

Examples

You might want to know what themes are enabled, so check core.themes

atom.config.get('core.themes')

With scope descriptors you can get settings within a specific editor scope. For example, you might want to know editor.tabLength for ruby files.

atom.config.get('editor.tabLength', scope: ['source.ruby']) # => 2

This setting in ruby files might be different than the global tabLength setting

atom.config.get('editor.tabLength') # => 4
atom.config.get('editor.tabLength', scope: ['source.ruby']) # => 2

You can get the language scope descriptor via TextEditor::getRootScopeDescriptor. This will get the setting specifically for the editor’s language.

atom.config.get('editor.tabLength', scope: @editor.getRootScopeDescriptor()) # => 2

Additionally, you can get the setting at the specific cursor position.

scopeDescriptor = @editor.getLastCursor().getScopeDescriptor()
atom.config.get('editor.tabLength', scope: scopeDescriptor) # => 2
Argument Description

keyPath

The String name of the key to retrieve.

options

optional

Object

sources

optional

Array of String source names. If provided, only values that were associated with these sources during ::set will be used.

excludeSources

optional

Array of String source names. If provided, values that were associated with these sources during ::set will not be used.

scope

optional

ScopeDescriptor describing a path from the root of the syntax tree to a token. Get one by calling {editor.getLastCursor().getScopeDescriptor()} See the scopes docs for more information.

Return values

Returns the value from Atom’s default settings, the user’s configuration file in the type specified by the configuration schema.

::set(keyPath, value, options)

Sets the value for a configuration setting.

This value is stored in Atom’s internal configuration file.

Examples

You might want to change the themes programmatically:

atom.config.set('core.themes', ['atom-light-ui', 'atom-light-syntax'])

You can also set scoped settings. For example, you might want change the editor.tabLength only for ruby files.

atom.config.get('editor.tabLength') # => 4
atom.config.get('editor.tabLength', scope: ['source.ruby']) # => 4
atom.config.get('editor.tabLength', scope: ['source.js']) # => 4

# Set ruby to 2
atom.config.set('editor.tabLength', 2, scopeSelector: '.source.ruby') # => true

# Notice it's only set to 2 in the case of ruby
atom.config.get('editor.tabLength') # => 4
atom.config.get('editor.tabLength', scope: ['source.ruby']) # => 2
atom.config.get('editor.tabLength', scope: ['source.js']) # => 4
Argument Description

keyPath

The String name of the key.

value

The value of the setting. Passing undefined will revert the setting to the default value.

options

optional

Object

scopeSelector

optional

String. eg. ‘.source.ruby’ See the scopes docs for more information.

source

optional

String The name of a file with which the setting is associated. Defaults to the user’s config file.

Return values

Returns a Boolean

  • true if the value was set.
  • false if the value was not able to be coerced to the type specified in the setting’s schema.

::unset(keyPath, options)

Restore the setting at keyPath to its default value.

Argument Description

keyPath

The String name of the key.

options

optional

Object

scopeSelector

optional

String. See ::set

source

optional

String. See ::set

Extended Methods

::getAll(keyPath, options)

Get all of the values for the given key-path, along with their associated scope selector.

Argument Description

keyPath

The String name of the key to retrieve

options

optional

Object see the options argument to ::get

Return values

Returns an Array of Objects with the following keys:

  • scopeDescriptor The ScopeDescriptor with which the value is associated
  • value The value for the key-path

::getSources()

Get an Array of all of the source Strings with which settings have been added via ::set.

::getSchema(keyPath)

Retrieve the schema for a specific key path. The schema will tell you what type the keyPath expects, and other metadata about the config option.

Argument Description

keyPath

The String name of the key.

Return values

Returns an Object eg. {type: 'integer', default: 23, minimum: 1}.

Returns null when the keyPath has no schema specified, but is accessible from the root schema.

::transact(callback)

Suppress calls to handler functions registered with ::onDidChange and ::observe for the duration of callback. After callback executes, handlers will be called once if the value for their key-path has changed.

Argument Description

callback

Function to execute while suppressing calls to handlers.

  • Terms of Use
  • Privacy
  • Code of Conduct
  • Releases
  • FAQ
  • Contact
  • Contribute!
with by