You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: book/02-using-atom/sections/02-text.asc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,3 @@
1
-
:compat-mode:
2
1
[[_moving_in_atom]]
3
2
=== Moving in Atom
4
3
@@ -255,6 +254,7 @@ There is a text file in your `~/.atom` directory called `snippets.cson` that con
255
254
256
255
There is also a directory called `~/.atom/snippets` that you can fill with multiple `json` or `cson` files in the snippets format if you want to organize your snippets in a more coherent way.
257
256
257
+
[[_snippet_format]]
258
258
===== Snippet Format
259
259
260
260
So let's look at how to write a snippet. The basic snippet format looks like this:
Copy file name to clipboardExpand all lines: book/02-using-atom/sections/05-writing.asc
-16Lines changed: 0 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,3 @@
1
-
:compat-mode:
2
1
[[_atom_markdown]]
3
2
=== Writing in Atom
4
3
@@ -55,18 +54,3 @@ If you type `img` and hit `tab` you get Markdown formatted image embed code like
55
54
----
56
55
57
56
There are only a handful of them (`b` for bold, `i` for italic, 'code' for a code block, etc), but it can easily save you time from having to look up the more obscure syntaxes. Again, you can easily see a list of all available snippets for the type of file you're currently in by hitting 'alt-shift-S'.
58
-
59
-
==== Wrapping customization
60
-
61
-
Many people prefer for their prose files to soft wrap lines but not their code. Atom allows you to customize settings for specific grammars, so we can easily override the wrapping settings specifically for our prose files.
62
-
63
-
Open your config file via the command palette type ``open config'', and hit enter. Add a snippet of configuration text like this:
64
-
65
-
[source,js]
66
-
----
67
-
'.source.gfm': # markdown overrides
68
-
'editor':
69
-
'softWrap': true
70
-
----
71
-
72
-
This will set the soft wrapping on by default for any Markdown files.
Copy file name to clipboardExpand all lines: book/02-using-atom/sections/06-customizing.asc
+78-29Lines changed: 78 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,37 @@
1
1
[[_basic_customization]]
2
2
=== Basic Customization
3
3
4
-
* on load script
5
-
* customizing
6
-
* look/feel - css, styleguide
7
-
* default file grammar
8
-
* config settings
9
-
* language specific settings
10
-
- different wraps for different grammars
4
+
Now that we are feeling comfortable with just about everything built into Atom, let's look at how to tweak it. Perhaps there is a keybinding that you use a lot but feels wrong or a color that isn't quite right for you. Atom is amazingly flexible, so let's go over some of the simpler flexes it can do.
5
+
6
+
==== Style Tweaks
7
+
8
+
If you want to apply quick-and-dirty personal styling changes without creating an entire theme that you intend to publish, you can add styles to the `styles.less` file in your `~/.atom` directory.
9
+
10
+
You can open this file in an editor from the _Atom > Open Your Stylesheet_ menu.
11
+
12
+
.Open your stylesheet
13
+
image::images/menubar.png[open stylesheet]
14
+
15
+
For example, to change the color of the cursor, you could add the following rule to your _~/.atom/styles.less_ file:
16
+
17
+
[source,css]
18
+
----
19
+
atom-text-editor.is-focused .cursor {
20
+
border-color: pink;
21
+
}
22
+
----
23
+
24
+
To see what classes are available to style the easiest thing to do is to inspect the DOM manually via the developer tools. We'll go over the developer tools in great detail in the next chapter, but for now let's take a simple look.
25
+
26
+
You can open the Developer Tools by hitting `alt-cmd-I`, which will bring up the Chrome developer tools panel.
27
+
28
+
.Developer Tools
29
+
image::images/devtools.png[developer tools]
30
+
31
+
You can now easily inspect all the elements in your current editor. If you want to update the style of something, you simply need to figure out what classes it has and write a LESS rule into your styles file to modify it.
32
+
33
+
If you are unfamiliar with LESS, it is a basic CSS preprocessor, making some things in CSS a bit easier. You can learn more about it at http://www.lesscss.org[lesscss.org]. If you prefer to use CSS instead, this file can also be named _styles.css_ and contain CSS.
11
34
12
-
https://github.com/atom/styleguide
13
35
14
36
==== Customizing Key Bindings
15
37
@@ -32,7 +54,7 @@ You can open this file in an editor from the _Atom > Open Your Keymap_ menu.
32
54
33
55
You'll want to know all the commands available to you. Open the Settings panel (`cmd-,`) and select the _Keybindings_ tab. It will show you all the keybindings currently in use.
34
56
35
-
==== Advanced Configuration
57
+
==== Global Configuration Settings
36
58
37
59
Atom loads configuration settings from the `config.cson` file in your _~/.atom_ directory, which contains CoffeeScript-style JSON: https://github.com/atom/season[CSON].
38
60
@@ -82,38 +104,65 @@ You can open this file in an editor from the _Atom > Open Your Config_ menu.
82
104
** `columns`: Array of hashes with a `pattern` and `column` key to match the
83
105
the path of the current editor to a column position.
84
106
85
-
==== Quick Personal Hacks
86
-
87
-
===== init.coffee
107
+
==== Language Specific Configuration Settings
88
108
89
-
When Atom finishes loading, it will evaluate _init.coffee_ in your _~/.atom_ directory, giving you a chance to run arbitrary personal CoffeeScript code to make customizations. You have full access to Atom's API from code in this file. If customizations become extensive, consider creating a package, which we will cover in <<_creating_a_package>>.
109
+
You can also set several configuration settings differently for different file types. For example, you may want Atom to soft wrap markdown files, have two-space tabs for ruby files, and four-space tabs for python files.
90
110
91
-
You can open this file in an editor from the _Atom > Open Your Init Script_ menu.
111
+
There are several settings now scoped to an editor's language. Here is the current list:
92
112
93
-
For example, if you have the Audio Beep configuration setting enabled, you could add the following code to your _~/.atom/init.coffee_ file to have Atom greet you with an audio beep every time it loads:
94
-
95
-
[source,coffee]
113
+
[source]
96
114
----
97
-
atom.beep()
115
+
editor.tabLength
116
+
editor.softWrap
117
+
editor.softWrapAtPreferredLineLength
118
+
editor.preferredLineLength
119
+
editor.scrollPastEnd
120
+
editor.showInvisibles
121
+
editor.showIndentGuide
122
+
editor.nonWordCharacters
123
+
editor.invisibles
124
+
editor.autoIndent
125
+
editor.normalizeIndentOnPaste
98
126
----
99
127
100
-
This file can also be named _init.js_ and contain JavaScript code.
128
+
===== Language-specific Settings in the Settings View
101
129
102
-
===== styles.less
130
+
You can edit these config settings in the settings view on a per-language basis. Just search for the language of your choice in the left panel, select it, and edit away!
103
131
104
-
If you want to apply quick-and-dirty personal styling changes without creating an entire theme that you intend to publish, you can add styles to the _styles.less_ file in your _~/.atom_ directory.
You can open this file in an editor from the _Atom > Open Your Stylesheet_ menu.
135
+
===== Language-specific Settings in your Config File
107
136
108
-
For example, to change the color of the cursor, you could add the following rule to your _~/.atom/styles.less_ file:
137
+
You can also edit the actual configuration file directly. Open your config file via the Command Palette, type ``open config'', and hit enter.
109
138
110
-
[source,css]
139
+
Global settings are under a global key, and each language can have its own top-level key. This key is the language's scope. Language-specific settings override anything set in the global section.
140
+
141
+
[source,javascript]
111
142
----
112
-
atom-text-editor.is-focused .cursor {
113
-
border-color: pink;
114
-
}
143
+
'global': # all languages unless overridden
144
+
'editor':
145
+
'softWrap': false
146
+
'tabLength': 8
147
+
148
+
'.source.gfm': # markdown overrides
149
+
'editor':
150
+
'softWrap': true
151
+
152
+
'.source.ruby': # ruby overrides
153
+
'editor':
154
+
'tabLength': 2
155
+
156
+
'.source.python': # python overrides
157
+
'editor':
158
+
'tabLength': 4
115
159
----
116
160
117
-
Unfamiliar with LESS? You can read more about it at http://www.lesscss.org
161
+
===== Finding a language's scope name
162
+
163
+
In order to write these overrides effectively, you'll need to know the scope name for the language. We've already done this for finding a scope for writing a snippet in <<_snippet_format>>, but we can quickly cover it again.
164
+
165
+
The scope name is shown in the settings view for each language. Search for the language of your choice in the left panel, select it, and you should see the scope name under the language name heading:
118
166
119
-
This file can also be named _styles.css_ and contain CSS.
0 commit comments