diff --git a/README.md b/README.md index ffb58ac481..4a5945938c 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ This book is open source under a Creative Commons license. To check the current progress and planned content of the book, check out the [outline](outline.md). - ## How To Generate the Book There are two ways to generate e-book content from this source code. diff --git a/book/01-introduction/images/advanced-settings.png b/book/01-introduction/images/advanced-settings.png index 8fd4e532f9..cd0e8648d7 100644 Binary files a/book/01-introduction/images/advanced-settings.png and b/book/01-introduction/images/advanced-settings.png differ diff --git a/book/01-introduction/images/command-palette.png b/book/01-introduction/images/command-palette.png index 0020e47a13..d49c39fa5a 100644 Binary files a/book/01-introduction/images/command-palette.png and b/book/01-introduction/images/command-palette.png differ diff --git a/book/01-introduction/images/finder.png b/book/01-introduction/images/finder.png index 8bd4cb0124..266a360a91 100644 Binary files a/book/01-introduction/images/finder.png and b/book/01-introduction/images/finder.png differ diff --git a/book/01-introduction/images/first-launch.png b/book/01-introduction/images/first-launch.png index 43ce693f06..46d6259cf8 100644 Binary files a/book/01-introduction/images/first-launch.png and b/book/01-introduction/images/first-launch.png differ diff --git a/book/01-introduction/images/linux-downloads.png b/book/01-introduction/images/linux-downloads.png index bb887998c6..577615fda6 100644 Binary files a/book/01-introduction/images/linux-downloads.png and b/book/01-introduction/images/linux-downloads.png differ diff --git a/book/01-introduction/images/open-file.png b/book/01-introduction/images/open-file.png index f559f8d084..6118bd1f2b 100644 Binary files a/book/01-introduction/images/open-file.png and b/book/01-introduction/images/open-file.png differ diff --git a/book/01-introduction/images/project-view.png b/book/01-introduction/images/project-view.png index 2931ee351e..4d0c779698 100644 Binary files a/book/01-introduction/images/project-view.png and b/book/01-introduction/images/project-view.png differ diff --git a/book/01-introduction/images/settings-wrap.png b/book/01-introduction/images/settings-wrap.png index 2e3377166d..b702760826 100644 Binary files a/book/01-introduction/images/settings-wrap.png and b/book/01-introduction/images/settings-wrap.png differ diff --git a/book/01-introduction/images/settings.png b/book/01-introduction/images/settings.png index 56f887b3f8..8251f1fe75 100644 Binary files a/book/01-introduction/images/settings.png and b/book/01-introduction/images/settings.png differ diff --git a/book/01-introduction/images/theme.png b/book/01-introduction/images/theme.png index d03d82dc24..de8ca5c028 100644 Binary files a/book/01-introduction/images/theme.png and b/book/01-introduction/images/theme.png differ diff --git a/book/01-introduction/sections/03-basics.asc b/book/01-introduction/sections/03-basics.asc index 8741fb3179..61eb6b3202 100644 --- a/book/01-introduction/sections/03-basics.asc +++ b/book/01-introduction/sections/03-basics.asc @@ -10,6 +10,16 @@ image::images/first-launch.png[Atom welcome screen] This is the Atom welcome screen and gives you a pretty good starting point for how to get started with the editor. +==== Basic Terminology + +First of all, let's get acquainted with some of the terminology we'll be using in this manual. + +Buffer:: + A buffer is the text content of a file in Atom. It's basically the same as a file for most descriptions, but it's the version Atom has in memory. For instance, you can change the text of a buffer and it isn't written to it's associated file until you save it. + +Pane:: + A pane is a visual section of Atom. If you look at the welcome screen we just launched, you can see four Panes - the tab bar, the gutter (which has line numbers in it), the status bar at the bottom and finally the text editor. + ==== Command Palette In that welcome screen, we are introduced to probably the most important command in Atom, the ``Command Palette''. If you hit `cmd-shift-P` while focused in an editor pane, the command palette will pop up. @@ -54,8 +64,6 @@ The UI themes modify the color of UI elements like the tabs and the tree view, w There are also dozens of themes on Atom.io that you can choose from if you want something different. We will also cover customizing a theme in <<_customizing_themes>> and creating your own theme in <<_creating_themes>>. -TODO: screenshot of various themes on Atom.io - ===== Soft Wrap You can also use the Settings view to specify your whitespace and wrapping preferences. diff --git a/book/02-using-atom/1-using-atom.asc b/book/02-using-atom/1-using-atom.asc index 788aec7d46..c4b56196b3 100644 --- a/book/02-using-atom/1-using-atom.asc +++ b/book/02-using-atom/1-using-atom.asc @@ -13,12 +13,12 @@ include::sections/03-interface.asc[] include::sections/04-git-markdown.asc[] -include::sections/05-customizing.asc[] +include::sections/05-writing.asc[] -include::sections/06-common-packages.asc[] +include::sections/06-customizing.asc[] === Summary -At this point you should be something of an Atom master user. You should be able to navigate and manipulate your text and files like a wizard. You should also be able to customize Atom backwards and forwards to make it your ultimate editing environment. +At this point you should be something of an Atom master user. You should be able to navigate and manipulate your text and files like a wizard. You should also be able to customize Atom backwards and forwards to make it look and act just how you want it to. Next we're going to take the next step, which is to look at changing and adding new functionality to the core of Atom itself. We're going to start creating packages for Atom. If you can dream it, you can build it. diff --git a/book/02-using-atom/images/autocomplete.png b/book/02-using-atom/images/autocomplete.png new file mode 100644 index 0000000000..a1bc2a1275 Binary files /dev/null and b/book/02-using-atom/images/autocomplete.png differ diff --git a/book/02-using-atom/images/bookmarks.png b/book/02-using-atom/images/bookmarks.png new file mode 100644 index 0000000000..84a351acec Binary files /dev/null and b/book/02-using-atom/images/bookmarks.png differ diff --git a/book/02-using-atom/images/devtools.png b/book/02-using-atom/images/devtools.png new file mode 100644 index 0000000000..d10dade969 Binary files /dev/null and b/book/02-using-atom/images/devtools.png differ diff --git a/book/02-using-atom/images/dictionary.png b/book/02-using-atom/images/dictionary.png new file mode 100644 index 0000000000..8ce8aa6e21 Binary files /dev/null and b/book/02-using-atom/images/dictionary.png differ diff --git a/book/02-using-atom/images/encodings.png b/book/02-using-atom/images/encodings.png new file mode 100644 index 0000000000..462490735d Binary files /dev/null and b/book/02-using-atom/images/encodings.png differ diff --git a/book/02-using-atom/images/find-replace-file.png b/book/02-using-atom/images/find-replace-file.png new file mode 100644 index 0000000000..1d1a05f722 Binary files /dev/null and b/book/02-using-atom/images/find-replace-file.png differ diff --git a/book/02-using-atom/images/find-replace-project.png b/book/02-using-atom/images/find-replace-project.png new file mode 100644 index 0000000000..326a105a37 Binary files /dev/null and b/book/02-using-atom/images/find-replace-project.png differ diff --git a/book/02-using-atom/images/folding.png b/book/02-using-atom/images/folding.png new file mode 100644 index 0000000000..77166943d8 Binary files /dev/null and b/book/02-using-atom/images/folding.png differ diff --git a/book/02-using-atom/images/git-checkout-head.gif b/book/02-using-atom/images/git-checkout-head.gif new file mode 100644 index 0000000000..95ce2271f6 Binary files /dev/null and b/book/02-using-atom/images/git-checkout-head.gif differ diff --git a/book/02-using-atom/images/git-lines.png b/book/02-using-atom/images/git-lines.png new file mode 100644 index 0000000000..c1cd5219f6 Binary files /dev/null and b/book/02-using-atom/images/git-lines.png differ diff --git a/book/02-using-atom/images/git-message.gif b/book/02-using-atom/images/git-message.gif new file mode 100644 index 0000000000..b57026604e Binary files /dev/null and b/book/02-using-atom/images/git-message.gif differ diff --git a/book/02-using-atom/images/git-status-bar.png b/book/02-using-atom/images/git-status-bar.png new file mode 100644 index 0000000000..2147cb2de8 Binary files /dev/null and b/book/02-using-atom/images/git-status-bar.png differ diff --git a/book/02-using-atom/images/git-status.gif b/book/02-using-atom/images/git-status.gif new file mode 100644 index 0000000000..67be72b374 Binary files /dev/null and b/book/02-using-atom/images/git-status.gif differ diff --git a/book/02-using-atom/images/goto.png b/book/02-using-atom/images/goto.png new file mode 100644 index 0000000000..5d3c2a3873 Binary files /dev/null and b/book/02-using-atom/images/goto.png differ diff --git a/book/02-using-atom/images/grammar.png b/book/02-using-atom/images/grammar.png new file mode 100644 index 0000000000..960cce19ca Binary files /dev/null and b/book/02-using-atom/images/grammar.png differ diff --git a/book/02-using-atom/images/menubar.png b/book/02-using-atom/images/menubar.png new file mode 100644 index 0000000000..3feba1f6dd Binary files /dev/null and b/book/02-using-atom/images/menubar.png differ diff --git a/book/02-using-atom/images/multiple-cursors.gif b/book/02-using-atom/images/multiple-cursors.gif new file mode 100644 index 0000000000..5700948b7b Binary files /dev/null and b/book/02-using-atom/images/multiple-cursors.gif differ diff --git a/book/02-using-atom/images/open-on-github.png b/book/02-using-atom/images/open-on-github.png new file mode 100644 index 0000000000..f54732de5c Binary files /dev/null and b/book/02-using-atom/images/open-on-github.png differ diff --git a/book/02-using-atom/images/package-settings.png b/book/02-using-atom/images/package-settings.png index 11fa115ee2..e7591627ee 100644 Binary files a/book/02-using-atom/images/package-settings.png and b/book/02-using-atom/images/package-settings.png differ diff --git a/book/02-using-atom/images/packages.png b/book/02-using-atom/images/packages.png index e92e2167d7..71b7247e1d 100644 Binary files a/book/02-using-atom/images/packages.png and b/book/02-using-atom/images/packages.png differ diff --git a/book/02-using-atom/images/panes.png b/book/02-using-atom/images/panes.png new file mode 100644 index 0000000000..ae8a4054d0 Binary files /dev/null and b/book/02-using-atom/images/panes.png differ diff --git a/book/02-using-atom/images/preview.png b/book/02-using-atom/images/preview.png new file mode 100644 index 0000000000..53732a6fc7 Binary files /dev/null and b/book/02-using-atom/images/preview.png differ diff --git a/book/02-using-atom/images/python-grammar.png b/book/02-using-atom/images/python-grammar.png new file mode 100644 index 0000000000..ce4a33bbe6 Binary files /dev/null and b/book/02-using-atom/images/python-grammar.png differ diff --git a/book/02-using-atom/images/python-settings.png b/book/02-using-atom/images/python-settings.png new file mode 100644 index 0000000000..54067e44a3 Binary files /dev/null and b/book/02-using-atom/images/python-settings.png differ diff --git a/book/02-using-atom/images/snippet-scope.png b/book/02-using-atom/images/snippet-scope.png new file mode 100644 index 0000000000..f14a0b50d7 Binary files /dev/null and b/book/02-using-atom/images/snippet-scope.png differ diff --git a/book/02-using-atom/images/snippets.png b/book/02-using-atom/images/snippets.png new file mode 100644 index 0000000000..ff01c595c8 Binary files /dev/null and b/book/02-using-atom/images/snippets.png differ diff --git a/book/02-using-atom/images/spellcheck.png b/book/02-using-atom/images/spellcheck.png new file mode 100644 index 0000000000..f0238c5c3a Binary files /dev/null and b/book/02-using-atom/images/spellcheck.png differ diff --git a/book/02-using-atom/images/symbol.png b/book/02-using-atom/images/symbol.png new file mode 100644 index 0000000000..c0bc6029b7 Binary files /dev/null and b/book/02-using-atom/images/symbol.png differ diff --git a/book/02-using-atom/images/themes.png b/book/02-using-atom/images/themes.png index 082e0988fa..fbfc0010d2 100644 Binary files a/book/02-using-atom/images/themes.png and b/book/02-using-atom/images/themes.png differ diff --git a/book/02-using-atom/images/unity-theme.png b/book/02-using-atom/images/unity-theme.png index 7f2a22037e..db791505d5 100644 Binary files a/book/02-using-atom/images/unity-theme.png and b/book/02-using-atom/images/unity-theme.png differ diff --git a/book/02-using-atom/images/whitespace.png b/book/02-using-atom/images/whitespace.png new file mode 100644 index 0000000000..a9c5e60baa Binary files /dev/null and b/book/02-using-atom/images/whitespace.png differ diff --git a/book/02-using-atom/sections/01-packages-themes.asc b/book/02-using-atom/sections/01-packages-themes.asc index 454f2b43f5..f1840d7c52 100644 --- a/book/02-using-atom/sections/01-packages-themes.asc +++ b/book/02-using-atom/sections/01-packages-themes.asc @@ -7,7 +7,9 @@ In fact, there are more than 70 packages that comprise all of the functionality This means that packages can be incredibly powerful and can change everything from the very look and feel of the entire interface to the basic operation of even core functionality. -In order to install a new package, you can use the Packages tab in the now familiar Settings view. Simply open up the Settings view (`cmd-,`), click on the ``Packages'' tab and type your seach query into the box under Install Packages that hints ``Search Packages''. This will go to the atom.io package registry and pull in anything that matches your search terms. +In order to install a new package, you can use the Packages tab in the now familiar Settings view. Simply open up the Settings view (`cmd-,`), click on the ``Packages'' tab and type your seach query into the box under Install Packages that hints ``Search Packages''. + +The packages listed here have been published to http://atom.io/packages[atom.io] which is the official registry for Atom packages. Searching on the settings pane will go to the atom.io package registry and pull in anything that matches your search terms. .Package install screen image::images/packages.png[Package install screen] @@ -27,7 +29,7 @@ Clicking on one of the package names will give you the settings screen for the p If a new version of any of your packages is released, Atom will automatically detect it and you can upgrade the package from either this screen or from the main package search tab. This helps you easily keep all your installed packages up to date. [[_atom_themes]] -=== Atom Themes +==== Atom Themes You can also find and install new themes for Atom from the Settings view. These can be either UI themes or syntax highlighting themes and you can search for them from the ``Themes'' tab, just like searching for new packages. @@ -40,3 +42,57 @@ Clicking on ``Install'' will install the theme and make it available in the Them .Example of the Unity UI theme with Monokai syntax theme image::images/unity-theme.png[Theme search screen] + + +==== Command Line + +You can also install packages or themes from the command line using `apm`. + +Check that you have `apm` installed by running the following command in your +terminal: + +[source,shell] +---- +$ apm help install +---- + +You should see a message print out with details about the `apm install` command. + +If you do not, launch Atom and run the _Atom > Install Shell Commands_ menu to install the `apm` and `atom` commands. + +You can also install packages by using the `apm install` command: + +* `apm install ` to install the latest version. + +* `apm install @` to install a specific version. + +For example `apm install emmet@0.1.5` installs the `0.1.5` release of the https://github.com/atom/emmet[Emmet] package. + +You can also use `apm` to find new packages to install. If you run `apm search`, you can search the package registry for a search term. + +[source] +---- +$ apm search coffee +Search Results For 'coffee' (5) +├── coffee-trace Add smart trace statements to coffee files with one keypress each. (77 downloads, 3 stars) +├── coffee-navigator Code navigation panel for Coffee Script (557 downloads, 8 stars) +├── atom-compile-coffee This Atom.io Package compiles .coffee Files on save to .js files. (myJavascript.coffee -> myJavascript.js) (349 downloads, 4 stars) +├── coffee-lint CoffeeScript linter (3336 downloads, 18 stars) +└── git-grep `git grep` in atom editor (1224 downloads, 9 stars) +---- + +You can use `apm view` to see more information about a specific package. + + +[source] +---- +$ apm view git-grep +git-grep +├── 0.7.0 +├── git://github.com/mizchi/atom-git-grep +├── `git grep` in atom editor +├── 1224 downloads +└── 9 stars + +Run `apm install git-grep` to install this package. +---- diff --git a/book/02-using-atom/sections/02-text.asc b/book/02-using-atom/sections/02-text.asc index 5a35a2c662..4436766548 100644 --- a/book/02-using-atom/sections/02-text.asc +++ b/book/02-using-atom/sections/02-text.asc @@ -1,28 +1,342 @@ -:compat-mode: -[[_working_with_text]] -=== Working with Text - -* multiple cursors -- cmd-shift-L (selection to cursors) -- cntl-shift-up (add cursor up/down) -* line manipulation (move, indent, goto) -* case, delete, transpose -* recording and replaying -* change encoding, grammar -* bracket matching -* whitespace -* spell checking +[[_moving_in_atom]] +=== Moving in Atom + +While it's pretty easy to move around Atom by clicking with the mouse or using the arrow keys, there are some keybindings that may help you keep your hands on the keyboard and navigate around a little faster. + +First of all, Atom ships with many of the basic Emacs keybindings for navigating a document. To go up and down a single character, you can use `ctrl-P` and `ctrl-N`. To go left and right a single character, you can use `ctrl-B` and `ctrl-F`. These are the equivalent of using the arrow keys, though some people prefer to not have to move their hands to where the arrow keys are located on their keyboard. + +In addition to single character movement, there are a number of other movement keybindings. + +`alt-B`, `alt-left`:: Move to beginning of word +`alt-F`, `alt-right`:: Move to end of word +`cmd-right`, `ctrl-E`:: Move to end of line +`cmd-left`, `ctrl-A`:: Move to first character of line +`cmd-up`:: Move to top of file +`cmd-down`:: Move to bottom of file + +You can also move directly to a specific line (and column) number with `ctrl-G`. This will bring up a dialog that asks which line you would like to jump to. You can also use the `row:column` syntax to jump to a character in that line as well. + +.Go directly to a line +image::images/goto.png[Go to line] + +==== Navigating by Symbols + +You can also jump around a little more informatively. To jump to a symbol such as a method definition, press `cmd-r`. This opens a list of all symbols in the current file, which you can fuzzy filter similarly to `cmd-t`. To search for symbols across your project, use `cmd-shift-r`. + +.Search by symbol across your project +image::images/symbol.png[Search by symbol across your project] + +You can also use `ctrl-alt-down` to jump directly to the declaration of the method or function under the cursor. + +First you'll need to make sure you have `tags` (or `TAGS`) file generated for your project. This can be done by installing http://ctags.sourceforge.net[ctags] and running a command such as `ctags -R src/` from the command line in your project's root directory. + +If you're on a Mac using http://brew.sh/[Homebrew], you can just run `brew install ctags`. + +You can customize how tags are generated by creating your own `.ctags` file in your home directory (`~/.ctags`). An example can be found https://github.com/atom/symbols-view/blob/master/lib/.ctags[here]. + +The symbols navigation functionality is implemented in the https://github.com/atom/symbols-view[atom/symbols-view] package. + +[[_atom_bookmarks]] +==== Atom Bookmarks + +Atom also has a great way to bookmark specific lines in your project so you can jump back to them quickly. + +If you press `cmd-F2`, Atom will toggle a ``bookmark'' on the current line. You can set these throughout your project and use them to quickly find and jump to important lines of your project. A small bookmark symbol is added to the line gutter, like on line 73 of <<_bookmarks_image>>. + +If you hit `F2`, Atom will jump to the next bookmark in the file you currently have focused. If you use `shift-F2` it will cycle backwards through them instead. + +You can also see a list of all your projects current bookmarks and quickly filter them and jump to any of them by hitting `ctrl-F2`. + +[[_bookmarks_image]] +.View and filter bookmarks. +image::images/bookmarks.png[] + +The bookmarks functionality is implemented in the https://github.com/atom/bookmarks[atom/bookmarks] package. [[_atom_selections]] === Atom Selections +Selecting ranges of text in Atom can be useful for a number of things. It can be for scoping certain actions like deleting, searching or indenting. It can also be helpful for things like quoting or bracketing text. + +Selections mirror many of the movement commands. They're actually exactly the same keybindings as the movement commands, but with a `shift` key added in. + +`ctrl-shift-P`:: Select up +`ctrl-shift-N`:: Select down +`ctrl-shift-B`:: Select previous character +`ctrl-shift-F`:: Select next character +`alt-shift-B`, `alt-shift-left`:: Select to beginning of word +`alt-shift-F`, `alt-shift-right`:: Select to end of word +`ctrl-shift-E`, `cmd-shift-right`:: Select to end of line +`ctrl-shift-A`, `cmd-shift-left`:: Select to first character of line +`cmd-shift-up`:: Select to top of file +`cmd-shift-down`:: Select to bottom of file + +In addition to the cursor movement selection commands, there are also a few commands that help with selecting specific areas of content. + +`cmd-A`:: Select the entire buffer +`cmd-L`:: Select entire line +`ctrl-shift-W`:: Select current word + +[[_working_with_text]] +=== Editing and Deleting Text + +So far we've looked at a number of ways to move around and select regions of a file, so now lets actually change some of that text. Obviously you can type in order to insert characters, but there are also a number of ways to delete and manipulate text that could come in handy. + +==== Basic Manipulation + +There are a handful of cool keybindings for basic text manipulation that might come in handy. These range from moving around lines of text and duplicating lines to changing the case. + +`ctrl-T`:: Transpose characters. This swaps the two characters on either side of the cursor. + +`cmd-J`:: Join the next line to the end of the current line + +`ctrl-cmd-up`, `ctrl-cmd-down`:: Move the current line up or down + +`cmd-shift-D`:: Duplicate the current line + +`cmd-K, cmd-U`:: Upper case the current word + +`cmd-K, cmd-L`:: Lower case the current word + +Atom also has built in functionality to re-flow a paragraph to hard-wrap at a given maximum line length. You can format the current selection to have lines no longer than 80 (or whatever number `editor.preferredLineLength` is set to) characters using `cmd-alt-Q`. If nothing is selected, the current paragraph will be reflowed. + +==== Deleting and Cutting + +You can also delete or cut text out of your buffer with some shortcuts. Be ruthless. + +`ctrl-shift-K`:: Delete current line + +`cmd-delete`:: Delete to end of line (`cmd-fn-backspace` on mac) + +`ctrl-K`:: Cut to end of line + +`cmd-backspace`:: Delete to beginning of line + +`alt-backspace`, `alt-H`:: Delete to beginning of word + +`alt-delete`, `alt-D`:: Delete to end of word + +==== Multiple Cursors and Selections + +One of the cool things that Atom can do out of the box is support multiple cursors. This can be incredibly helpful in manipulating long lists of text. + +`cmd-click`:: Add new cursor + +`cmd-shift-L`:: Convert a multi-line selection into multiple cursors + +`ctrl-shift-up`, `ctrl-shift-up`:: Add another cursor above/below the current cursor + +`cmd-D`:: Select the next word in the document that is the same as the currently selected word + +`ctrl-cmd-G`:: Select all words in document that are the same as the one under the current cursor(s) + +Using these commands you can place cursors in multiple places in your document and effectively execute the same commands in multiple places at once. + +.Using multiple cursors +image::images/multiple-cursors.gif[using multiple cursors] + +This can be incredibly helpful in doing many type of repetitive tasks such as renaming variables or changing the format of some text. You can use this with almost any plugin or command - for example, changing case and moving or duplicating lines. + +You can also use the mouse to select text with the `command` key pressed down to select multiple regions of your text simultaneously. + +==== Whitespace + +Atom comes with a couple of tools to help you manage the whitespace in your document. These tools are implemented in the https://github.com/atom/whitespace[atom/whitespace] package. + +The first is a command that converts leading spaces to tabs and the equivalent for changing tabs into spaces. If you're working with a document that has mixed whitespace, these commands can be great for helping to normalize the file. There are no keybindings for these, so you will have to search your command palette for "Convert Spaces to Tabs" (or vice versa) to run one of these commands. + +The whitespace helper tools are maintained as a separate package and so the settings for it can be managed from the page for the `whitespace` package. + +.Managing your whitespace settings +image::images/whitespace.png[whitespace settings] + +Note that the ``Remove Training Whitespace'' option is on by default. This means that every time you save any file opened in Atom, it will strip all trailing whitesapce from the file. If you want to disable this, go to the `whitespace` package in your settings panel and uncheck that option. + +Atom will also by default ensure that your file has a trailing newline. You can also disable this option on that screen. + +==== Brackets + +Atom ships with intelligent and easy to use bracket handling. + +It will by default highlight [], (), and {} style brackets when your cursor is over them. It will also highlight matching XML and HTML tags. + +Atom will also automatically autocomplete [], (), and {}, "", '', “”, ‘’, «», ‹›, and backticks when you type the leading one. If you have a selection and you type any of these opening brackets or quotes, Atom will enclose the selection with the opening and closing brackets or quotes. + +There are a few other interesting bracket related commands that you can use. + +`ctrl-m`:: Jump to the bracket matching the one adjacent to the cursor. It jumps to the nearest enclosing bracket when there's no adjacent bracket. + +`ctrl-cmd-m`:: Select all the text inside the current brackets + +`alt-cmd-.`:: Close the current XML/HTML tag + +The brackets functionality is implemented in the https://github.com/atom/bracket-matcher[atom/bracket-matcher] package. Like all of these packages, to change defaults related to brackets handling, or to disable it entirely, you can navigate to this package in the Settings view. + +==== Encoding + +Atom also ships with some basic file encoding support should you find yourself working with non-UTF-8 encoded files, or should you wish to create one. + +`ctrl-shift-U`:: Toggle menu to change file encoding + +If you pull up the file encoding dialog, you can choose an alternate file encoding to save your file in. Normally it will auto-detect the encoding if it can, otherwise it will default to UTF-8. New files will also be UTF-8 files by default. + +.Changing your file encoding +image::images/encodings.png[file encodings] + +If you pull up the encoding menu and change the active encoding to something else, the file will be written out in that encoding the next time that you save the file. + +The encoding selector is implemented in the https://github.com/atom/encoding-selector[atom/encoding-selector] package. + [[_find_replace]] === Find and Replace -[[_moving_in_atom]] -=== Moving in Atom +Finding and replacing text in your file or project is quick and easy in Atom. -* tags/symbols +`cmd-F`:: Search within a buffer -[[_atom_bookmarks]] -=== Atom Bookmarks +`cmd-shift-f`:: Search the entire project + +If you launch either of those commands, you'll be greeted with the ``Find and Replace'' pane at the bottom of your screen. + +.Find and replace text in the current file +image::images/find-replace-file.png[find and replace file] + +To search within your current file you can hit `cmd-F`, type in a search string and hit enter (or `cmd-G` or the ``Find Next'' button) multiple times to cycle through all the matches in that file. There are also buttons to toggle case sensitivity, regular expression matching and selection scoping. + +If you type a string in the ``Replace in current buffer'' text box, you can replace matches with a different string. For example, if you wanted to replace every instance of the string ``Scott'' with the string ``Dragon'', you would enter those values in the two text boxes and hit the ``Replace All'' button to execute the replacements. + +You can also do this throughout your entire project if you invoke the panel with `cmd-shift-F`. + +.Find and replace text in your project +image::images/find-replace-project.png[find and replace project] + +This is a great way to find out where in your project a function is called, an anchor is linked to or a specific misspelling is located. Clicking on the matching line will jump you to that location in that file. + +Hit `escape` while focused on the Find and Replace pane to clear the pane from your workspace. + +The Find and Replace functionality is implemented in the https://github.com/atom/find-and-replace[atom/find-and-replace] package and uses the https://github.com/atom/scandal[atom/scandal] package to do the actual searching. + +[[_snippets]] +=== Snippets + +Snippets are an incredibly powerful way to quickly generate commonly needed code syntax from a shortcut. + +The idea is that you can type something like `habtm` and then hit the `tab` key and that will expand into `has_and_belongs_to_many`. + +Many of the packages come bundled with their own snippets that are specific to that mode. For example, the `language-html` package that provides support for HTML syntax highlighting and grammar comes with dozens of snippets to create many of the various HTML tags you might want to use. If you create a new HTML file in Atom, you can type `html` and then hit `tab` and it will expand to: + +[source,html] +---- + + + + + + + + +---- + +It will also position the cursor in the middle of the `title` tag so you can immediately start filling out the tag. Many snippets have multiple focus points that you can move through with the `tab` key as well - for instance, in the case of this HTML snippet, once you've filled out the title tag you can hit `tab` and the cursor will move to the middle of the body tag. + +To see all the available snippets for the file type that you currently have open, you can type `alt-shift-S`. + +.View all available snippets +image::images/snippets.png[view snippets] + +You can also use fuzzy search to filter this list down by typing in the selection box. Selecting one of them will execute the snippet where your cursor is (or multiple cursors are). + +==== Creating Your Own Snippets + +So that's pretty cool, but what if there is something the language package didn't include or something that is custom to the code you write? Luckily it's incredibly easy to add your own snippets. + +There is a text file in your `~/.atom` directory called `snippets.cson` that contains all your custom snippets that are loaded when you launch Atom. However, you can also easily open up that file by selecting the _Atom > Open Your Snippets_ menu. + +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. + +[[_snippet_format]] +===== Snippet Format + +So let's look at how to write a snippet. The basic snippet format looks like this: + +[source,coffee] +---- +'.source.js': + 'console.log': + 'prefix': 'log' + 'body': 'console.log(${1:"crash"});$2' +---- + +The outermost keys are the selectors where these snippets should be active. The easiest way to determine what this should be is to go to the language package of the language you want to add a snippet for and look for the ``Scope'' string. + +For example, if we wanted to add a snippet that would work for Java files, we would look up the `language-java` package in our Settings view and we can see the Scope is `source.java`. Then the top level snippet key would be that prepended by a period (like a CSS class selector would do). + +.Finding the selector scope for a snippet +image::images/snippet-scope.png[snippet scope] + +The next level of keys are the snippet names. These are used for describing the snippet in a more readable way in the snippet menu. It's generally best to use some sort of sort human readable string here. + +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. + +[source,js] +---- +console.log("crash"); +---- + +The string `"crash"` would be initially selected and pressing tab again would place the cursor after the `;` + +===== Multi-line Snippet Body + +You can also use multi-line syntax using `"""` for larger templates: + +[source,coffee] +---- +'.source.js': + 'if, else if, else': + 'prefix': 'ieie' + 'body': """ + if (${1:true}) { + $2 + } else if (${3:false}) { + $4 + } else { + $5 + } + """ +---- + +As you might expect, there is a snippet to create snippets. If you open up a snippets file and type `snip` and then hit `tab`, you will get the following text inserted: + +[source,coffee] +---- +'.source.js': + 'Snippet Name': + 'prefix': 'hello' + 'body': 'Hello World!' +---- + +Bam, just fill that bad boy out and you have yourself a snippet. As soon as you save the file, Atom should reload the snippets and you will immediately be able to try it out. + +The snippets functionality is implemented in the https://github.com/atom/snippets[atom/snippets] package. + +=== Autocomplete + +If you're still looking to save some typing time, Atom also ships with simple autocompletion functionality. + +The autocompleter lets you view and insert possible completions in the editor using `ctrl-space`. + +.Autocomplete menu +image::images/autocomplete.png[autocomplete] + +By default, the completer will look through the current open file for strings that match what you're starting to type. + +If you want more options, in the Settings panel for the Autocomplete package you can toggle a setting to make the autocompleter look for strings in all your open buffers rather than just the current file. + +For an even more powerful autocompletion solution, skip on over to the <<_autocomplete_plus>> package we cover in <<_common_packages>>. + +The Autocomplete functionality is implemented in the +https://github.com/atom/autocomplete[atom/autocomplete] package. diff --git a/book/02-using-atom/sections/03-interface.asc b/book/02-using-atom/sections/03-interface.asc index 201113009b..bdd434790d 100644 --- a/book/02-using-atom/sections/03-interface.asc +++ b/book/02-using-atom/sections/03-interface.asc @@ -1,11 +1,42 @@ -[[_key_bindings]] -=== Atom Keybindings - [[_atom_folding]] === Folding +If you want to see an overview of the structure of the code file you're working on, folding can be a helpful tool. Folding hides blocks of code such as functions or looping blocks in order to simplify what is on your screen. + +You can fold blocks of code by clicking the arrows that appear when you hover your mouse cursor over the gutter. You can also fold and unfold from the keyboard with the `alt-cmd-[` and `alt-cmd-]` keybindings. + +.Code folding example +image::images/folding.png[code folding] + +To fold everything, use `alt-cmd-shift-{` and to unfold everything use `alt-cmd-shift-}`. You can also fold at a specific indentation level with `cmd-k cmd-N` where N is the indentation depth. + +Finally, you can fold arbitrary sections of your code or text by making a selection and then hitting `ctrl-alt-cmd-F` or choosing ``Fold Selection'' in the Command Palette. + [[_atom_panes]] === Panes -* splitting, loading, resizing, focusing -* pain split package +You can split any editor pane horizontally or vertically by using `cmd-k arrow` where the arrow is the direction to split the pane . Once you have a split pane, you can move focus between them with `cmd-k cmd-arrow` where the arrow is the direction the focus should move to. + +.Multiple panes +image::images/panes.png[panes] + +Each pane has it's own ``items'' or files, which are represented by tabs. You can move the files from pane to pane by dragging them with the mouse and dropping them in the pane you want that file to be in. + +To close a pane, close all its editors with `cmd-w`, then press `cmd-w` one more time to close the pane. You can configure panes to auto-close when empty in the Settings view. + +[[_grammar_selection]] +=== Grammar + +The ``grammar'' of a buffer is what language Atom thinks that file content is. Types of grammars would be Java or Markdown. We looked at this a bit when we created some snippets in <<_snippets>>. + +If you load up a file, Atom does a little work to try to figure out what type of file it is. Largely this is accomplished by looking at it's file extension (`.md` is generally a Markdown file, etc), though sometimes it has to inspect the content a bit to figure it out if it's ambiguous. + +If you load up a file and Atom can't determine a grammar for the file, it will default to 'Plain Text', which is the simplest one. If it does this, if it miscategorizes a file, or if for any reason you wish to change the active grammar of a file, you can pull up the Grammar selector with `ctrl-shift-L`. + +.Grammar selector +image::images/grammar.png[grammar selector] + +Once the grammar of a file is changed manually, Atom will remember that until you set it back to auto-detect or choose a different grammar manually. + +The Grammar selector functionality is implemented in the +https://github.com/atom/grammar-selector[atom/grammar-selector] package. diff --git a/book/02-using-atom/sections/04-git-markdown.asc b/book/02-using-atom/sections/04-git-markdown.asc index 0edc4a009b..155734e81a 100644 --- a/book/02-using-atom/sections/04-git-markdown.asc +++ b/book/02-using-atom/sections/04-git-markdown.asc @@ -1,11 +1,81 @@ [[_atom_git]] -=== Git in Atom +=== Version Control in Atom -* working with git -* http://blog.atom.io/2014/03/13/git-integration.html -* git plugins +Version control is an important aspect of any project and Atom comes with basic http://git-scm.com[Git] and https://github.com[GitHub] integration baked in. -[[_atom_markdown]] -=== Markdown in Atom +==== Checkout HEAD revision -* editing markdown +The `cmd-alt-Z` keybinding checks out the HEAD revision of the file in the editor. + +This is a quick way to discard any saved and staged changes you've made and restore the file to the version in the HEAD commit. This is essentially the same as running `git checkout HEAD -- ` and `git reset HEAD -- ` from the command line for that path. + +.Git checkout HEAD +image::images/git-checkout-head.gif[git checkout head] + +This command goes onto the undo stack so you can use `cmd-Z` afterwards to restore the previous contents. + +==== Git status list + +Atom ships with the fuzzy-finder package which provides `cmd-T` to quickly open files in the project and `cmd-B` to jump to any open editor. + +The package also comes with `cmd-shift-B` which pops up a list of all the untracked and modified files in the project. These will be the same files that you would see on the command line if you ran git status. + +.Git status list +image::images/git-status.gif[git status] + +An octicon will appear to the right of each file letting you know whether it is untracked or modified. + +==== Commit editor + +Atom can be used as your Git commit editor and ships with the language-git package which adds syntax highlighting to edited commit, merge, and rebase messages. + +.Git commit message highlighting +image::images/git-message.gif[git message] + +You can configure Atom to be your Git commit editor with the following command: + +[source,shell] +---- +$ git config --global core.editor "atom --wait" +---- + +The https://github.com/atom/language-git[language-git] package will help you with your brevity by colorizing the first lines of commit messages when they're longer than 50 and 65 characters. + +==== Status bar icons + +The https://github.com/atom/language-git[status-bar] package that ships with Atom includes several Git decorations that display on the right side of the status bar. + +.Git Status Bar +image::images/git-status-bar.png[status bar] + +The currently checked out branch name is shown with the number of commits the branch is ahead of or behind its upstream branch. + +Also an icon is added if the file is untracked, modified, or ignored. The number of lines added and removed since the file was last committed will be displayed as well. + +==== Line diffs + +The included https://github.com/atom/git-diff[git-diff] package colorizes the gutter next to lines that have been added, edited, and removed. + +.Git line diffs +image::images/git-lines.png[git line diffs] + +This package also adds `alt-g down` and `alt-g up` keybindings that allow you to move the cursor to the next/previous diff hunk in the current editor. + +==== Open on GitHub + +If the project you're working on is on GitHub, there are also some very useful integrations you can use. Most of the commands will take the current file you're viewing and open a view of that file on GitHub - for instance, the blame or commit history of that file. + +`alt-G O`:: Open file on GitHub + +`alt-G B`:: Open blame of file on GitHub + +`alt-G H`:: Open history of file on GitHub + +`alt-G C`:: Copy the URL of the current file on GitHub + +`alt-G R`:: Branch compare on GitHub + +The branch comparison simply shows you the commits that are on the branch you're currently working on locally that are not on the mainline branch. + +.Open Blame of file on GitHub +image::images/open-on-github.png[open on github] diff --git a/book/02-using-atom/sections/05-customizing.asc b/book/02-using-atom/sections/05-customizing.asc deleted file mode 100644 index 9c43ca7e51..0000000000 --- a/book/02-using-atom/sections/05-customizing.asc +++ /dev/null @@ -1,14 +0,0 @@ -[[_basic_customization]] -=== Basic Customization - -* on load script -* customizing -* look/feel - css, styleguide -* keybindings -* default file grammar -* config settings -* language specific settings -- different wraps for different grammars -* autocomplete -* snippets -* emmet, autocomplete+ diff --git a/book/02-using-atom/sections/05-writing.asc b/book/02-using-atom/sections/05-writing.asc new file mode 100644 index 0000000000..1950016d98 --- /dev/null +++ b/book/02-using-atom/sections/05-writing.asc @@ -0,0 +1,56 @@ +[[_atom_markdown]] +=== Writing in Atom + +Though it is probably most common to use Atom to write software code, Atom can also be used to write prose quite effectively. Most often this is done in some sort of markup language such as Markdown or Asciidoc (as this manual is written in). Here we'll quickly cover a few of the tools Atom provides for helping you write prose. + +Here we'll concentrate on writing in Markdown, but other prose markup languages like Asciidoc have packages that provide similar functionality. + +==== Spell Checking + +If you're workng in text (which includes plain text files, GitHub markdown and Git commit messages by default), Atom will automatically try to check your spelling. + +Any misspelled words will be highlighted (by default with a dashed red line beneath the word) and you can pull up a menu of possible corrections by hitting `cmd-:` (or by choosing ``Correct Spelling'' from the right-click context menu or from the Command Palette). + +.Checking your spelling +image::images/spellcheck.png[spell checking] + +To add more types of files to the list of what Atom will try to spell check, go to the Spell Check package settings in your Settings view and add any grammars you want to spell check. + +By default it's set to ``text.plain, source.gfm, text.git-commit'' but you can add something like ``source.asciidoc'' if you wish to check those types of files too. + +The Atom spell checker uses the system dictionary, so if you want it to check your spelling in another language or locale, you can change it easily. + +.Changing your spell checking dictionary +image::images/dictionary.png[spell check dictionary] + +The spell checking is implemented in the https://github.com/atom/spell-check[atom/spell-check] package. + +==== Previews + +When writing prose in a markup language, it's often very useful to get an idea of what the content will look like when it's rendered. Atom ships with a markdown preview plugin by default. + +`cntl-shift-M`:: Will toggle Preview mode for Markdown. + +.Preview your prose +image::images/preview.png[preview prose] + +As you edit the text, the preview will also update by default. This makes it fairly easy to check your syntax as you type. + +You can also copy the rendered HTML from the preview pane into your system clipboard. There is no keybinding for it, but you can find it in the Command Palette by searching for ``Markdown Preview Copy HTML''. + +Markdown preview is implemented in the https://github.com/atom/markdown-preview[atom/markdown-preview] package. + +==== Snippets + +There are also a number of great snippets available for writing Markdown quickly. + +If you type `img` and hit `tab` you get Markdown formatted image embed code like `![]()`. If you type `table` and hit `tab` you get a nice example table to fill out. + +[source] +---- +| Header One | Header Two | +| :------------- | :------------- | +| Item One | Item Two | +---- + +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'. diff --git a/book/02-using-atom/sections/06-common-packages.asc b/book/02-using-atom/sections/06-common-packages.asc deleted file mode 100644 index cbb6d298fd..0000000000 --- a/book/02-using-atom/sections/06-common-packages.asc +++ /dev/null @@ -1,7 +0,0 @@ -[[_common_packages]] -=== Common Atom Packages - -* gist? -* github -* stack trace -* live archives diff --git a/book/02-using-atom/sections/06-customizing.asc b/book/02-using-atom/sections/06-customizing.asc new file mode 100644 index 0000000000..b8e304d049 --- /dev/null +++ b/book/02-using-atom/sections/06-customizing.asc @@ -0,0 +1,168 @@ +[[_basic_customization]] +=== Basic Customization + +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. + +==== Style Tweaks + +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. + +.Open your stylesheet +image::images/menubar.png[open stylesheet] + +For example, to change the color of the cursor, you could add the following rule to your _~/.atom/styles.less_ file: + +[source,css] +---- +atom-text-editor.is-focused .cursor { + border-color: pink; +} +---- + +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. + +You can open the Developer Tools by hitting `alt-cmd-I`, which will bring up the Chrome developer tools panel. + +.Developer Tools +image::images/devtools.png[developer tools] + +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. + +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. + + +==== Customizing Key Bindings + +Atom keymaps work similarly to stylesheets. Just as stylesheets use selectors to apply styles to elements, Atom keymaps use selectors to associate keystrokes with events in specific contexts. Here's a small example, excerpted from Atom's built-in keymaps: + +[source,coffee] +---- +'atom-text-editor': + 'enter': 'editor:newline' + +'atom-text-editor[mini] input': + 'enter': 'core:confirm' +---- + +This keymap defines the meaning of `enter` in two different contexts. In a normal editor, pressing `enter` emits the `editor:newline` event, which causes the editor to insert a newline. But if the same keystroke occurs inside of a select list's mini-editor, it instead emits the `core:confirm` event based on the binding in the more-specific selector. + +By default, `~/.atom/keymap.cson` is loaded when Atom is started. It will always be loaded last, giving you the chance to override bindings that are defined by Atom's core keymaps or third-party packages. + +You can open this file in an editor from the _Atom > Open Your Keymap_ menu. + +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. + +==== Global Configuration Settings + +Atom loads configuration settings from the `config.cson` file in your _~/.atom_ directory, which contains CoffeeScript-style JSON: https://github.com/atom/season[CSON]. + +[source,coffee] +---- +'core': + 'excludeVcsIgnoredPaths': true +'editor': + 'fontSize': 18 +---- + +The configuration itself is grouped by the package name or one of the two core namespaces: `core` and `editor`. + +You can open this file in an editor from the _Atom > Open Your Config_ menu. + +===== Configuration Key Reference + +* `core` +** `disabledPackages`: An array of package names to disable +** `excludeVcsIgnoredPaths`: Don't search within files specified by _.gitignore_ +** `ignoredNames`: File names to ignore across all of Atom +** `projectHome`: The directory where projects are assumed to be located +** `themes`: An array of theme names to load, in cascading order +* `editor` +** `autoIndent`: Enable/disable basic auto-indent (defaults to `true`) +** `nonWordCharacters`: A string of non-word characters to define word boundaries +** `fontSize`: The editor font size +** `fontFamily`: The editor font family +** `invisibles`: Specify characters that Atom renders for invisibles in this hash +*** `tab`: Hard tab characters +*** `cr`: Carriage return (for Microsoft-style line endings) +*** `eol`: `\n` characters +*** `space`: Leading and trailing space characters +** `preferredLineLength`: Identifies the length of a line (defaults to `80`) +** `showInvisibles`: Whether to render placeholders for invisible characters (defaults to `false`) +** `showIndentGuide`: Show/hide indent indicators within the editor +** `showLineNumbers`: Show/hide line numbers within the gutter +** `softWrap`: Enable/disable soft wrapping of text within the editor +** `softWrapAtPreferredLineLength`: Enable/disable soft line wrapping at `preferredLineLength` +** `tabLength`: Number of spaces within a tab (defaults to `2`) +* `fuzzyFinder` +** `ignoredNames`: Files to ignore *only* in the fuzzy-finder +* `whitespace` +** `ensureSingleTrailingNewline`: Whether to reduce multiple newlines to one at the end of files +** `removeTrailingWhitespace`: Enable/disable striping of whitespace at the end of lines (defaults to `true`) +* `wrap-guide` +** `columns`: Array of hashes with a `pattern` and `column` key to match the +the path of the current editor to a column position. + +==== Language Specific Configuration Settings + +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. + +There are several settings now scoped to an editor's language. Here is the current list: + +[source] +---- +editor.tabLength +editor.softWrap +editor.softWrapAtPreferredLineLength +editor.preferredLineLength +editor.scrollPastEnd +editor.showInvisibles +editor.showIndentGuide +editor.nonWordCharacters +editor.invisibles +editor.autoIndent +editor.normalizeIndentOnPaste +---- + +===== Language-specific Settings in the Settings View + +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! + +.Python specific settings +image::images/python-settings.png[python settings] + +===== Language-specific Settings in your Config File + +You can also edit the actual configuration file directly. Open your config file via the Command Palette, type ``open config'', and hit enter. + +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. + +[source,javascript] +---- +'global': # all languages unless overridden + 'editor': + 'softWrap': false + 'tabLength': 8 + +'.source.gfm': # markdown overrides + 'editor': + 'softWrap': true + +'.source.ruby': # ruby overrides + 'editor': + 'tabLength': 2 + +'.source.python': # python overrides + 'editor': + 'tabLength': 4 +---- + +===== Finding a language's scope name + +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. + +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: + +.Finding a language grammar +image::images/python-grammar.png[python grammar] diff --git a/book/cover.png b/book/cover.png index 219adcada7..46d1e804e5 100644 Binary files a/book/cover.png and b/book/cover.png differ diff --git a/outline.md b/outline.md index a573cc2196..d2e310e86e 100644 --- a/outline.md +++ b/outline.md @@ -23,7 +23,7 @@ * [ ] working with text * multiple cursors - cmd-shift-L (selection to cursors) - - cntl-shift-up (add cursor up/down) + - ctrl-shift-up (add cursor up/down) * line manipulation (move, indent, goto) * case, delete, transpose * recording and replaying diff --git a/scripts/crush.rb b/scripts/crush.rb new file mode 100755 index 0000000000..4c0a5b2939 --- /dev/null +++ b/scripts/crush.rb @@ -0,0 +1,29 @@ +#! /usr/bin/env ruby +require 'rubygems' +require 'oily_png' + +Dir.glob("book/**/*.png").each do |file| + puts file + image = ChunkyPNG::Image.from_file(file) + p image.width + p image.height + if image.width > 800 || image.height > 800 + if image.width > image.height + `convert -resize 800x #{file} #{file}.smaller.png` + else + `convert -resize x800 #{file} #{file}.smaller.png` + end + `pngcrush #{file}.smaller.png #{file}` + `rm #{file}.smaller.png` + end +end + + +# [2,0.5].each do |scale| +# resized_image = ChunkyPNG::Image.new((image.width * scale).round, (image.height * scale).round) +# resized_image.pixels.map!.with_index do |pixel, index| +# x, y = index % resized_image.width, (index / resized_image.width).floor +# image[x / scale, y / scale] +# end +# resized_image.save("bassie_resized_#{scale}.png") +# end