# Spacemacs Documentation
**Table of Contents**
- [Spacemacs Documentation](#spacemacs-documentation)
- [Philosophy](#philosophy)
- [Easy](#easy)
- [Consistency](#consistency)
- [Crowd-Configured](#crowd-configured)
- [Goals](#goals)
- [Screenshots](#screenshots)
- [Who can benefit from this ?](#who-can-benefit-from-this-)
- [Configuration layers](#configuration-layers)
- [Structure](#structure)
- [Extensions and Packages](#extensions-and-packages)
- [Declaration](#declaration)
- [Initialization](#initialization)
- [Exclusion](#exclusion)
- [Packages synchronization (Vundle like feature)](#packages-synchronization-vundle-like-feature)
- [Types of configuration layers](#types-of-configuration-layers)
- [Submitting a configuration layer upstream](#submitting-a-configuration-layer-upstream)
- [Example: Themes Megapack example](#example-themes-megapack-example)
- [Managing private configuration layers](#managing-private-configuration-layers)
- [Using the private directory](#using-the-private-directory)
- [Using an external Git repository](#using-an-external-git-repository)
- [Using a personal branch](#using-a-personal-branch)
- [Dotfile Configuration](#dotfile-configuration)
- [Installation](#installation)
- [Content](#content)
- [Using configuration layers](#using-configuration-layers)
- [Excluding packages](#excluding-packages)
- [Hooks](#hooks)
- [Custom variables](#custom-variables)
- [Using the package list buffer](#using-the-package-list-buffer)
- [Update all the packages](#update-all-the-packages)
- [Main principles](#main-principles)
- [Evil](#evil)
- [States](#states)
- [Base States](#base-states)
- [Evil leader](#evil-leader)
- [Universal argument](#universal-argument)
- [Micro-states](#micro-states)
- [Differences between Vim, Evil and Spacemacs](#differences-between-vim-evil-and-spacemacs)
- [The vim-surround case](#the-vim-surround-case)
- [Color theme](#color-theme)
- [UI elements](#ui-elements)
- [Toggles](#toggles)
- [Mode-line](#mode-line)
- [Flycheck integration](#flycheck-integration)
- [Anzu integration](#anzu-integration)
- [Battery status integration](#battery-status-integration)
- [Powerline separators](#powerline-separators)
- [Minor Modes](#minor-modes)
- [Base packages](#base-packages)
- [Evil plugins](#evil-plugins)
- [Font](#font)
- [Commands](#commands)
- [Reserved prefix command for user](#reserved-prefix-command-for-user)
- [Escaping](#escaping)
- [Executing Vim, Emacs and shell commands](#executing-vim-emacs-and-shell-commands)
- [Navigating](#navigating)
- [Point/Cursor](#pointcursor)
- [Smooth scrolling](#smooth-scrolling)
- [Experimental insert state feature](#experimental-insert-state-feature)
- [Vim motions with ace-jump mode](#vim-motions-with-ace-jump-mode)
- [Window manipulation](#window-manipulation)
- [Resizing windows](#resizing-windows)
- [Reposition window](#reposition-window)
- [Golden ratio](#golden-ratio)
- [Buffers and Files](#buffers-and-files)
- [Emacs and Spacemacs files](#emacs-and-spacemacs-files)
- [Ido](#ido)
- [Experimental Ido feature](#experimental-ido-feature)
- [NeoTree file tree](#neotree-file-tree)
- [NeoTree navigation](#neotree-navigation)
- [Opening files with NeoTree](#opening-files-with-neotree)
- [Other NeoTree key bindings](#other-neotree-key-bindings)
- [NeoTree mode-line](#neotree-mode-line)
- [Shells](#shells)
- [Key bindings](#key-bindings)
- [Staying in insert state](#staying-in-insert-state)
- [Bookmarks](#bookmarks)
- [Searching](#searching)
- [Project Searching](#project-searching)
- [Persistent highlighting](#persistent-highlighting)
- [Stacking highlights](#stacking-highlights)
- [Highlight current symbol](#highlight-current-symbol)
- [Visual Star](#visual-star)
- [Listing symbols by semantic](#listing-symbols-by-semantic)
- [Helm-swoop](#helm-swoop)
- [Editing](#editing)
- [Text manipulation commands](#text-manipulation-commands)
- [Smartparens Strict mode](#smartparens-strict-mode)
- [Zooming](#zooming)
- [Text](#text)
- [Frame](#frame)
- [Increase/Decrease numbers](#increasedecrease-numbers)
- [Spell checking](#spell-checking)
- [Region selection](#region-selection)
- [Expand-region](#expand-region)
- [Indent text object](#indent-text-object)
- [Region narrowing](#region-narrowing)
- [Line formatting](#line-formatting)
- [Auto-completion](#auto-completion)
- [Replacing text with iedit](#replacing-text-with-iedit)
- [iedit states key bindings](#iedit-states-key-bindings)
- [State transitions](#state-transitions)
- [In iedit state](#in-iedit-state)
- [In iedit-insert state](#in-iedit-insert-state)
- [Examples](#examples)
- [Commenting](#commenting)
- [Deleting files](#deleting-files)
- [Editing Lisp code](#editing-lisp-code)
- [Key bindings maps](#key-bindings-maps)
- [Regular normal state bindings](#regular-normal-state-bindings)
- [Lisp specific bindings](#lisp-specific-bindings)
- [Project management](#project-management)
- [Registers](#registers)
- [Errors handling](#errors-handling)
- [Compiling](#compiling)
- [Modes](#modes)
- [Major Mode leader key](#major-mode-leader-key)
- [Helm](#helm)
- [Experimental Helm feature](#experimental-helm-feature)
- [Ledger](#ledger)
- [Org](#org)
- [Python](#python)
- [JavaScript](#javascript)
- [rcirc](#rcirc)
- [HTML and CSS](#html-and-css)
- [Emacs Server](#emacs-server)
- [Connecting to the Emacs server](#connecting-to-the-emacs-server)
- [Keeping the server alive](#keeping-the-server-alive)
- [Troubleshoot](#troubleshoot)
- [Loading fails](#loading-fails)
- [I have no file ~/.spacemacs](#i-have-no-file-spacemacs)
- [Tips](#tips)
- [evil-lisp-state as default state](#evil-lisp-state-as-default-state)
- ["jk" to trigger evil leader](#jk-to-trigger-evil-leader)
- [Achievements](#achievements)
- [Thank you](#thank-you)
# Philosophy
Three core pillars: Easy, Consistency, "Crowd-Configured".
## Easy
`Spacemacs` organizes key bindings by mnemonic namespaces. If you are looking
for commands to operate on your buffer, they are right under SPC b,
if you want to operate on your project, then it is SPC p, etc...
`Spacemacs` comes with a dedicated major mode `spacemacs-mode`. Its goal is to
give useful feedbacks and perform maintenance tasks easily.
## Consistency
Similar functionalities should have the same key binding. For instance if you are
looking for the definition of a function, the binding is SPC m g,
`m` for `major mode` and `g` for `go to`. And no matter what is the major mode it
should be the same binding.
## Crowd-Configured
This term does not really exist but I'm sure you know what it means.
This is the most powerful feature of `Spacemacs`. Anybody can submit upstream
his or her configuration layer and anybody can use it in a second by adding it
in a dotfile and by optionally filtering it (ie. removing unwanted packages).
So by cloning this repository you have a centralized place of configured
packages tuned by expert in their domain. And most importantly it should be
consistent with the whole experience provided by `Spacemacs`.
If some packages are missing from core `Spacemacs` but they are present in
several contribution layers, chances are that they should be in core and we
can easily move them there.
If any of this core pillars are violated open an issue and we'll try to fix
this.
# Goals
- **Bring the power of modal editing** to the powerful Emacs editing platform.
- Integrate nicely with `Evil` states (`Vim` modes): `Spacemacs` tries to
**keep your fingers on the home row** as much as possible, no matter the mode
you are in.
- **Crowed-configured**: Contribute your own personal layer upstream and
everybody can use it.
- **Minimalistic and nice UI**, keep your available screen space for what
matters: your text files.
- **Mnemonic and consistent key bindings** which should be easier to learn
and remember.
- **Fast boot time**.
- **Lower the risk of RSI**.
- Hopefully, if it's not already the case:
Ɛ>Ɛ>Ɛ> **make you love modal editing!** <3<3<3
# Screenshots
_Startup_
![spacemacs_startup](img/spacemacs-startup.png)
_Python_
![spacemacs_python](img/spacemacs-python.png)
_Terminal (urxvt)_
![spacemacs_urxvt](img/spacemacs-urxvt.png)
*Note: Even though screenshots are updated frequently, `Spacemacs` is evolving
quickly and the screenshots may not reflect exactly the current state of the
project.*
# Who can benefit from this ?
`Spacemacs` is first intended to be used by **Vim users** who want to go to the
next level by using Emacs.
It is also a good fit for people wanting to **lower the [risk of RSI][RSI]**
induced by the default Emacs key bindings.
Emacs users wanting to learn **a different way to edit files** or wanting to
learn Vim key bindings (see [Tips for Emacs users](#tips-for-emacs-users)).
As a side note, if you are a programmer and you don't know Vim key bindings
yet, I deeply recommend you to learn the basics as recommended in
[Sacha Chua's one-page guide][sacha_guide] about how to learn Emacs.
# Configuration layers
_This part of Spacemacs is still in beta, the structure can change over
time. Refer to commit messages for more information in case of big changes._
## Structure
Configuration is organized in layers. Each layer has the following structure:
```
[layer_name]
|__ [extensions]
| |__ [mode 1]
| | ...
| |__ [mode n]
|__ config.el
|__ extensions.el
|__ funcs.el
|__ keybindings.el
|__ packages.el
[] = directory
```
Where:
File | Usage
------------------|-----------------------------------------------------------
config.el | Emacs built-in configuration or mandatory configuration
extensions.el | The list of extensions to load and the functions to initialize them
funcs.el | Various functions and macros (often used in keybindings.el)
keybindings.el | Emacs built-in key bindings or mandatory key bindings
packages.el | The list of packages to install and the functions to initialize them
`Packages` are `ELPA` packages which can be installed from an `ELPA` compliant
repository, and `Extensions` are generally elisp code from git submodules.
## Extensions and Packages
### Declaration
`Extensions` and `Packages` are declared in variables `-pre-extensions`,
`-post-extensions` and `-packages` where `` is the layer
name. `Pre-Extensions` are loaded before `Packages` and `Post-Extensions` are
loaded after `Packages`.
They are processed in alphabetical order so sometimes you'll have to use
some `eval-after-load` black magic.
Example:
```elisp
(defvar -packages
'(
package1
package2
)
```
### Initialization
To initialize an extension or a package `xxx`, define a function with this
format in `extensions.el` or `packages.el`:
```elisp
(defun /init-xxx ()
...body
)
```
It is common to define the body with the [use-package][use-package] macro.
### Exclusion
It is possible to exclude some packages from `Spacemacs` in a per layer basis.
This is useful when a configuration layer aims to replace a stock package
declared in the `Spacemacs` layer.
To do so add the package names to exclude to the variable
`-excluded-packages`.
Example:
```elisp
(defvar -excluded-packages
'(
package1
)
```
## Packages synchronization (Vundle like feature)
`Spacemacs` features a synchronization engine for the ELPA packages. It means
that `Spacemacs` will auto-install the new packages in `-packages` lists
_and_ auto-delete orphan packages in your `elpa` directory.
It effectively makes `Spacemacs` to behave like [Vundle][vundle].
## Types of configuration layers
There are three types of configuration layers:
- core (this is the `Spacemacs` layer)
- private (in the `private` directory, they are ignored by Git)
- contrib (in the `contrib` directory, those layers are contributions shared by
the community and merged upstream).
## Submitting a configuration layer upstream
If you decide to provide a `contrib` configuration layer, please check
the contribution guidelines in [CONTRIBUTE.md][].
## Example: Themes Megapack example
This is a simple `contrib` configuration layer listing a bunch of themes,
you can find it [here][themes-megapack].
To install it, just add `themes-megapack` to your `~/.spacemacs` like so:
```elisp
dotspacemacs-configuration-layers '(themes-megapack)
```
You have now installed around 100 themes you are free to try with SPC T h
(helm-themes).
## Managing private configuration layers
`Spacemacs` configuration system is flexible enough to let you manage your
private layers in different ways.
### Using the private directory
Everything in the private directory is ignored by Git so it is a good place
to store private layers. There is a huge drawback to this approach though:
_your layers are not source controlled_.
### Using an external Git repository
This is the recommended way to manage your private layers.
The best approach is to store all your private layers into an external Git
repository. It is especially a good practice to store them in your `dotfiles`
repository if you have one. Put also your `~/.spacemacs` file in it.
Then you are free to symlink your layers into `~/emacs.d/private` _or_ let
them anywhere you want and reference the parent directory in the variable
`dotspacemacs-configuration-layer-path` of your `~/.spacemacs`.
Note that you could also have a dedicated repository for all your private
layers and then directly clone this repository in `~/.emacs.d/private`.
### Using a personal branch
The final main way to manage your private layers is to push them in a personal
branch that you keep up to date with upstream `master` or `develop`.
# Dotfile Configuration
User configuration can be stored in your `~/.spacemacs` file.
## Installation
`~/.spacemacs` is an optional file. If you want to use it you have to copy it
manually from the template file `~/.emacs.d/core/templates/.spacemacs.template`
```sh
$ cp ~/.emacs.d/core/templates/.spacemacs.template ~/.spacemacs
```
## Content
### Using configuration layers
To use a configuration layer, add it to the `dotspacemacs-configuration-layers`
variable of your `~/.spacemacs`.
For instance to add the configuration layer of [RMS](#thank-you):
```elisp
(setq-default dotspacemacs-configuration-layers '(rms))
```
If this layer does not exist you can still try another one in
[the `contrib` directory](https://github.com/syl20bnr/spacemacs/tree/master/contrib).
Configuration layers are expected to be stored in `~/.emacs.d/private` or
`~/.emacs.d/contrib`. But you are free to keep them somewhere else by declaring
additional paths where `Spacemacs` can look for configuration layers.
This is done by setting the list
`dotspacemacs-configuration-layer-path` in your `~/.spacemacs`:
```elisp
(setq-default dotspacemacs-configuration-layer-path '("~/.myconfig/"))
```
### Excluding packages
You can exclude packages you don't want to install with the variable
`dotspacemacs-excluded-packages`, this variable can exclude both packages and
extensions (see [Configuration layers](#configuration-layers) for more info
on packages and extensions).
For instance to disable the `rainbow-delimiters` package:
```elisp
(setq-default dotspacemacs-excluded-packages '(rainbow-delimiters))
```
When you exclude a package, `Spacemacs` will automatically delete it for you
the next time you launch Emacs. All the orphan dependencies are as well
delete automatically.
### Hooks
Two special functions of the `~/.spacemacs` file can be used to perform
configuration at the beginning and end of `Spacemacs` loading process.
- `dotspacemacs/init` is triggered at the very beginning of `Spacemacs`
loading.
- `dotspacemacs/config` is triggered at the very end of `Spacemacs` loading.
### Custom variables
Custom variables configuration from `M-x customize-group` which are
automatically saved by Emacs are stored at the end of your `~/.spacemacs`
file.
# Using the package list buffer
The package list buffer is where you can selectively update one or all
packages installed in your configuration as well as browse for all
available packages in the different Elpa repositories.
`Spacemacs` replaces the default package list buffer with [Paradox][].
Paradox enhances the package list buffer with better feedbacks, new
filters and Github information like the number of stars. Optionally you
can also star packages directly in the buffer.
**Important Note** Don't install new packages from the package list
buffer. If those packages are not referenced in a configuration layer
then `Spacemacs` will treat them as orphans during the next start of
Emacs and they will be deleted.
Key Binding | Description
---------------------|------------------------------------------------------------
/ | evil-search
f k | filter by keywords
f r | filter by regexp
f u | display only installed package with updates available
h | go left
H | show help (not accurate)
j | go down
k | go up
l | go right
L | show last commits
n | next search occurrence
N | previous search occurrence
o | open package homepage
r | refresh
S P | sort by package name
S S | sort by status (installed, available, etc...)
S * | sort by Github stars
v | `visual state`
V | `visual-line state`
x | execute (action flags)
## Update all the packages
To update all the buffers:
- open paradox: SPC a P
- filter packages (optional): f u
- update all: U x y
When asked for old packages deletion hit `y`.
# Main principles
## Evil
`Spacemacs` uses the [evil][evil] mode to emulate Vim key bindings. It is a
very complete emulation, maybe the most advanced. In fact, Evil is much more
than just a Vim emulation. It has more states than Vim for instance.
### States
`Spacemacs` has 8 states:
- **Normal** (orange) - like the `normal mode of Vim`, used to execute and
combine commands
- **Insert** (green) - like the `insert mode of Vim`, used to actually insert
text
- **Visual** (gray) - like the `visual mode of Vim`, used to make text
selection
- **Motion** (purple) - exclusive to `Evil`, used to navigate read only
buffers
- **Emacs** (blue) - exclusive to `Evil`, using this state is like using a
regular Emacs without Vim
- **Lisp** (pink) - exclusive to `Spacemacs`, used to navigate Lisp code and
modify it (see [Editing Lisp code](#editing-lisp-code))
- **Iedit** (red) - exclusive to `Spacemacs`, used to navigate between multiple
regions of text using `iedit`
(see [Replacing text with iedit](#replacing-text-with-iedit))
- **Iedit Insert** (red) - exclusive to `Spacemacs`, used to replace multiple
regions of text using `iedit`
(see [Replacing text with iedit](#replacing-text-with-iedit))
Note: Technically speaking there are also the `operator` and `replace` evil
states.
### Base States
_(I apologize in advance for the number of repetition of the word `state` in
this section, but I encourage you to read again this section until you correctly
grasp the concept of `base state` since it is an important concept in
`Spacemacs`)_
`Spacemacs` has a notion of `base state`. A `base state` is the state you are
when leaving the `insert state`.
The typical `base state` in Vim is the `normal state` and it is the only one.
`Spacemacs` has more than one base state, here is the list:
- normal
- lisp
This allows a coder of Lisp to completely replace the `normal state` by the
`lisp state`. Indeed, once you fire up the `lisp state` you can just go back
and forth between the `insert state` and the `lisp state`.
Of course there is a rule to break this in order to be able to go back to the
`normal state`. It is pretty simple:
*When in a `base state`, `ESC` or the key chord `fd` will always set you back to the
`normal state`.*
So to go back to the `normal state` while in `lisp state` just hit `ESC` or hit both
`fd` together.
## Evil leader
`Spacemacs` heavily uses the [evil-leader][evil-leader] mode which brings the
Vim leader key to the Emacs world.
This leader key is commonly set to `,` by Vim users, in `Spacemacs` the leader
key is set on SPC (space bar, this is why the name `spacemacs`).
This key is the most accessible key on a keyboard and it is pressed with the
thumb which is a good choice to lower the risk of [RSI][RSI].
So with `Spacemacs` there is no need to remap your keyboard modifiers to
attempt to reduce the risk of RSI, every command can be executed very easily
while you are in `normal` mode by pressing the SPC leader key,
here are a few examples:
- Save a buffer: SPC f s
- Save all opened buffers: SPC f S
- Open (switch) to a buffer with `helm`: SPC b s
## Universal argument
The universal argument `C-u` is an important command in Emacs but it is also
a very handy Vim key binding to scroll up.
`Spacemacs` binds C-u to `scroll-up` and change the universal
argument binding to SPC u.
## Micro-states
`Spacemacs` defines a wide variety of `micro-states` (temporary overlay maps)
where it makes sense. This prevent from repetitive and tedious presses on the
SPC key.
When a `micro-state` is active, a documentation is displayed in the minibuffer.
Additional information may as well be displayed in the minibuffer.
[Auto-highlight-symbol micro-state](#auto-highlight-and-edition-of-symbols):
![spacemacs_ahs_micro_state](img/spacemacs-ahs-micro-state.png)
[Text scale micro-state](#change-font-size):
![spacemacs_scale_micro_state](img/spacemacs-scale-micro-state.png)
# Differences between Vim, Evil and Spacemacs
No doubt that `Evil` is one of the most advanced `Vim` emulation and you should
not see big difference between `Vim` and `Emacs`. I did not find any command I
used in Vim that I missed in Emacs with `Evil`.
Send a PR to add the differences you found in this section.
## The vim-surround case
There is one obvious visible difference though. It is not between `Evil` and
`Vim` but between `Spacemacs` and [vim-surround][]: the `surround` command is
on S in `vim-surround` whereas it is on s in `Spacemacs`.
This is something that can surprise some Vim users so let me explain why this is
the case:
- `s` and `c` do the same thing in `visual state`,
- `s` is only useful to delete _one_ character and add more than one character
which is a _very_ narrow use case,
- `c` accept motions and can do everything `s` can do in `normal state`,
- this is also true for `r` but `r` is more useful because it stays in
`normal state`.
- `surround` command is just a more powerful command that `s`
If you are not convinced, then here is the snippet to revert back to the default
`Vim + vim-surround` setup (add it to your `dotspacemacs/config` function or
your `~/.spacemacs`):
```elisp
(evil-define-key 'visual evil-surround-mode-map "s" 'evil-substitute)
(evil-define-key 'visual evil-surround-mode-map "S" 'evil-surround-region)
```
# Color theme
By default, `Spacemacs` uses the theme [solarized-light][solarized-theme].
It is possible to define your default theme in your `~/.spacemacs` with
the variable `dotspacemacs-default-theme`. For instance, to specify `zenburn`:
```elisp
(setq-default
;; Default theme applied at startup
dotspacemacs-default-theme 'zenburn)
```
Some themes are supported by `Spacemacs`:
- [Solarized][solarized-theme]
- [Leuven][leuven-theme]
- [Monokai][monokai-theme]
- [Zenburn][zenburn-theme]
It is possible to set any other themes but their compatibility with `Spacemacs`
is not guaranteed (i.e. there may be some missing faces etc...).
Key Binding | Description
---------------------|------------------------------------------------------------
SPC T n | switch to next theme supported by `Spacemacs`.
SPC h t | select a theme using a `helm` buffer.
**Note:** Due to the inner working of themes in Emacs, switching theme during
the same session may have some weird side effects. Although these side effects
should be pretty rare (especially when switching to a supported theme).
**Hint** If you are an `Org` user, [leuven-theme][] is amazing.
# UI elements
`Spacemacs` has a minimalistic and distraction free UI with a lot of subtle
customization which make it unique compared to other kits:
- beautiful custom [powerline][powerline] mode-line
[with color feedback](#flycheck-integration) according to current
[Flycheck][flycheck]
status
- unicode symbols for minor mode lighters which appear in the mode-line
- [custom fringe bitmaps](#errors-handling) and error feedbacks for
[Flycheck][flycheck]
- [custom fringe bitmaps](../contrib/git/README.md#git-gutter-bitmaps) for [git gutter][]
- dedicated startup page with a mode aimed at easily managing `Spacemacs`
## Toggles
Some UI indicators can be toggled on and off (toggles start with `t`):
Key Binding | Description
----------------------|------------------------------------------------------------
SPC t 8 | display a mark on the 80th column
SPC t F | toggle frame fullscreen
SPC t f | toggle display of the fringe
SPC t i | toggle aggressive indent
SPC t l | toggle truncate lines
SPC t L | toggle visual lines
SPC t M | toggle frame maximize
SPC t n | show the absolute line numbers
SPC t t | toggle frame transparency
## Mode-line
The mode line is an heavily customized [powerline][powerline] with the
following capabilities:
- show the window number
- color code for current state
- show the number of search occurrences via anzu
- toggle flycheck info
- toggle battery info
- toggle minor mode lighters
Reminder of the color codes for the states:
Evil State | Color
-------------------|------------------
Normal | Orange
Insert | Green
Visual | Grey
Emacs | Blue
Motion | Purple
Lisp | Pink
Iedit/Iedit-Insert | Red
Some elements can be dynamically toggled:
Key Binding | Description
-----------------------|------------------------------------------------------------
SPC t m m | toggle the minor mode lighters
SPC t m b | toggle the battery status
SPC t m f | toggle the flycheck info
### Flycheck integration
When [Flycheck][flycheck] minor mode is enabled, a new element appears showing
the number of errors, warnings and info.
![powerline-wave](img/powerline-wave.png)
### Anzu integration
[Anzu][anzu] shows the number of occurrence when performing a search. `Spacemacs`
integrates nicely the Anzu status by displaying it temporarily when `n` or `N` are
being pressed. See the `5/6` segment on the screenshot below.
![powerline-anzu](img/powerline-anzu.png)
### Battery status integration
[fancy-battery][] displays the percentage of total charge of the battery as
well as the time remaining to charge or discharge completely the battery.
A color code is used for the battery status:
Battery State | Color
------------------|------------------
Charging | Green
Discharging | Orange
Critical | Red
Note the these colors may vary depending on your theme.
### Powerline separators
It is possible to easily customize the `powerline separator` by setting the
`powerline-default-separator` variable in your `~./spacemacs`. For instance
if you want to set back the separator to the well-known `arrow` separator
add the following snippet to your configuration file:
```elisp
(defun dotspacemacs/config ()
"This is were you can ultimately override default Spacemacs configuration.
This function is called at the very end of Spacemacs initialization."
(setq powerline-default-separator 'arrow)
)
```
To save you the time to try all the possible separators provided by the
powerline, here is an exhaustive set of screenshots:
Separator | Screenshot
------------------|------------------------------------------------------------
`alternate` | ![powerline-alternate](img/powerline-alternate.png)
`arrow` | ![powerline-arrow](img/powerline-arrow.png)
`arrow-fade` | ![powerline-arrow-fade](img/powerline-arrow-fade.png)
`bar` | ![powerline-bar](img/powerline-bar.png)
`box` | ![powerline-box](img/powerline-box.png)
`brace` | ![powerline-brace](img/powerline-brace.png)
`butt` | ![powerline-butt](img/powerline-butt.png)
`chamfer` | ![powerline-chamfer](img/powerline-chamfer.png)
`contour` | ![powerline-contour](img/powerline-contour.png)
`curve` | ![powerline-curve](img/powerline-curve.png)
`rounded` | ![powerline-rounded](img/powerline-rounded.png)
`roundstub` | ![powerline-roundstub](img/powerline-roundstub.png)
`slant` | ![powerline-slant](img/powerline-slant.png)
`wave` | ![powerline-wave](img/powerline-wave.png)
`zigzag` | ![powerline-zigzag](img/powerline-zigzag.png)
`nil` | ![powerline-nil](img/powerline-nil.png)
### Minor Modes
`Spacemacs` uses [diminish][diminish] mode to reduce the size of minor mode
indicators:
The minor mode area can be toggled on and off with:
t m m
Unicode symbols are displayed by default. Setting the variable
`dotspacemacs-mode-line-unicode-symbols` to `nil` in your `~/.spacemacs` will
display ASCII characters instead (may be useful in terminal).
Unicode | ASCII | Mode
:-----------:|:----------:|----------------------------------------------------
`⊞` | G | [golden-ratio][golden-ratio] mode
`Ⓐ` | A | [auto-complete][auto-complete] mode
`Ⓒ` | C | [centered-cursor][centered-cursor] mode
`Ⓔ` | E | [evil-org][evil-org-mode] mode
`Ⓕ` | F | flycheck mode
`Ⓚ` | K | guide-key mode
`Ⓘ` | I | aggressive indent mode
`(Ⓟ)` | (P) | paredit mode
`Ⓢ` | S | flyspell mode
`(Ⓢ)` | (S) | [smartparens][sp] mode
`Ⓦ` | W | whitespace mode
`Ⓨ` | Y | [yasnippet][yasnippet] mode
# Base packages
`Spacemacs` main mechanics rely largely on `Evil` and `Helm` base packages.
They are both extended with various packages to build on their foundations.
## Evil plugins
`Spacemacs` ships with the following evil plugins:
Mode | Description
----------------------------------------|--------------------------------------
[evil-leader][] | vim leader that bring a new layer of keys in normal mode
[evil-indent-textobject][] | add text object based on indentation level
[evil-visualstar][] | search for current selection with `*`
[evil-exchange][] | port of [vim-exchange][]
[evil-surround][] | port of [vim-surround][]
[evil-nerd-commenter][] | port of [nerdcommenter][]
[evil-search-highlight-persist][] | emulation of hlsearch behavior
[evil-numbers][] | like C-a/C-x in vim
[evil-args][] | motions and text objects for arguments
[evil-jumper][] | jump list emulation
[NeoTree][neotree] | mimic [NERD Tree][nerdtree]
# Font
The default font used by `Spacemacs` is [source code pro][] by Adobe. It is
recommended to install it on your system.
Basic font support is provided in `Spacemacs`, you can change the font and
its size using the function `spacemacs/set-font` in the `dotspacemacs/config`
function of your `~/.spacemacs`.
```elisp
(defun dotspacemacs/config ()
(spacemacs/set-font "DejaVu Sans Mono" 10)
)
```
# Commands
Every sequences must be performed in `normal` mode.
## Reserved prefix command for user
SPC o is reserved for the user. Setting key bindings behind ` o`
is **guaranteed** to never conflict with `Spacemacs` defaults key bindings.
## Escaping
`Spacemacs` uses [evil-escape][] to easily switch between `insert state` and
`normal state` with the key chord `fd`.
The choice of `fd` was made to be able to use the same sequence to escape from
"everything" in Emacs:
- escape from all evil states to normal state
- escape from evil-lisp-state to normal state
- abort evil ex command
- quit minibuffer
- abort isearch
- quit magit buffers
- quit help buffers
- quit apropos buffers
- quit ert buffers
- quit undo-tree buffer
- quit paradox
- quit gist-list menu
- hide neotree buffer
This sequence can be customized in your `~/.spacemacs`, but `evil-escape`
is not guaranteed to work properly with sequences based on `h j k or l` so
it is recommended to avoid defining sequences like `jj` or `jk`.
Example to set it to `jn` (it is important to put it in `dotspacemacs/init`):
```elisp
(defun dotspacemacs/init ()
(setq-default evil-escape-key-sequence (kbd "jn"))
)
```
## Executing Vim, Emacs and shell commands
Command | Key Binding
:---------------:|------------------------------------------------------------------
Vim (ex-command) | `:`
Emacs (M-x) | SPC :
Shell | SPC ! or just !
The command key `:` can be easily changed with the variable
`dotspacemacs-command-key` of your `~/.spacemacs`. Note that is will change both
`:` and `SPC :` bindings to keep the symmetry between Vim and Emacs. A good
key can be `,` for example.
## Navigating
### Point/Cursor
Navigation is performed using the Vi key bindings `hjkl`.
Key Binding | Description
---------------------|------------------------------------------------------------------
`h` | move cursor left
`j` | move cursor down
`k` | move cursor up
`l` | move cursor right
`H` | move quickly up (10 lines at a time)
`L` | move quickly down (10 lines at a time)
SPC j h | go to the beginning of line (and set a mark at the previous location in the line)
SPC j l | go to the end of line (and set a mark at the previous location in the line)
SPC z z | lock the cursor at the center of the screen
#### Smooth scrolling
[smooth-scrolling]() prevent the point to jump when it reaches the top or
bottom of the screen. It is enabled by default.
On Windows, you may want to disable it. To disable the smooth scrolling set
the `dotspacemacs-smooth-scrolling` variable in your `~/.spacemacs` to `nil`:
```elisp
(setq-default dotspacemacs-smooth-scrolling t)
```
#### Experimental insert state feature
If `dotspacemacs-feature-toggle-leader-on-jk` is non nil, pressing `jk` while
in `insert state` will trigger the evil leader as if you pressed SPC in
normal mode.
### Vim motions with ace-jump mode
`Spacemacs` uses the `evil` integration of [ace-jump mode][ace-jump] which
enables the invocation of `ace-jump-mode` during motions.
It is useful for deleting visually a set of lines, try the following sequence
in a buffer containing some text:
d l
Key Binding | Description
---------------------|------------------------------------------------------------------
SPC SPC | initiate ace jump word mode
SPC l | initiate ace jump line mode
SPC ` | go back to the previous location (before the jump)
Hint: you may change to char mode by `C-c C-c` in word mode.
### Window manipulation
Every window has a number displayed at the start of the mode-line and can
be quickly accessed using ` number`.
Key Binding | Description
--------------------|----------------------------------------------------------------
SPC 1 | go to first window
SPC 2 | go to window number 2
SPC 3 | go to window number 3
SPC 4 | go to window number 4
SPC 5 | go to window number 5
SPC 6 | go to window number 6
SPC 7 | go to window number 7
SPC 8 | go to window number 8
SPC 9 | go to window number 9
SPC 0 | go to window number 10
Windows manipulation commands (start with `w`):
Key Binding | Description
------------------------------------------|----------------------------------------------------------------
SPC w c | close a window
SPC w d | toggle window dedication (dedicated window cannot be reused by a mode)
SPC w H | move window to the left
SPC w J | move window to the bottom
SPC w K | move window to the top
SPC w L | move window to the right
SPC w m | maximize/minimize a window
SPC w M | maximize/minimize a window, when maximized the buffer is centered
SPC w o | cycle and focus between frames
SPC w p m | open messages buffer in a popup window
SPC w p p | close the current sticky popup window
SPC w r | initiate window size micro-state
SPC w R | rotate windows clockwise
SPC w s or SPC w / | horizontal split
SPC w S | horizontal split and focus new window
SPC w u | undo window layout (used to effectively undo a closed window)
SPC w U | redo window layout
SPC w v or SPC w - | vertical split
SPC w V | vertical split and focus new window
SPC w w | cycle and focus between windows
#### Resizing windows
`Spacemacs` defines a micro-state to resize windows.
Key Binding | Description
--------------------|------------------------------------------------------------
SPC w S | initiate micro-state
H | shrink window horizontally
J | shrink window vertically
K | enlarge window vertically
L | enlarge window horizontally
Any other key | leave the micro-state
The micro-state text in minibuffer display the following information:
[WidthxHeight] Resize window: (H/L) shrink/enlarge horizontally, (J/K) shrink/enlarge vertically
#### Reposition window
Key Binding | Description
--------------------|------------------------------------------------------------
z f | Make current function or comments visible
`z f` tries to accommodate current function or comments into window as much as possible.
#### Golden ratio
If you resize windows like crazy you may want to give a try to [golden-ratio][].
`golden-ratio` resizes windows dynamically depending on whether they are
selected or not. By default `golden-ratio` is off.
The mode can be toggled on and off with:
t g
### Buffers and Files
`Spacemacs` uses `ido` for opening files since `ido` way to navigate
the file system is better than `helm` in my opinion (especially because `ido` can
remember the last selected directories and buffers, maybe helm can do this ?).
`ido` is also used to kill buffers.
Buffer manipulation commands (start with `b`):
Key Binding | Description
------------------------------------------|----------------------------------------------------------------
SPC b b or SPC TAB | switch to alternate buffer (switch back and forth)
SPC b e | erase the content of the buffer (ask for confirmation)
SPC b k | kill the current buffer
SPC b K | kill all buffers except the current one
SPC b C-K | kill all buffers matching the regexp
SPC b m h | move a buffer to the left
SPC b m j | move a buffer to the bottom
SPC b m k | move a buffer to the top
SPC b m l | move a buffer to the right
SPC b n | switch to next buffer
SPC b p | switch to previous buffer
SPC b r | rename the current buffer
SPC b R | revert the current buffer (reload from disk)
SPC b s | switch to a buffer using `helm`
SPC b w | toggle read-only (writable state)
Files manipulation commands (start with `f`):
Key Binding | Description
------------------------------------------|----------------------------------------------------------------
SPC f d | delete a file and the associated buffer (ask for confirmation)
SPC f f | open a file using `ido`
SPC f s | save a file
SPC f S | save all files
SPC f r | open a recent file with `helm`
SPC f t | toggle file tree side bar using [NeoTree][neotree]
SPC f y | show current file absolute path in the minibuffer
#### Emacs and Spacemacs files
Convenient key bindings are located under the prefix SPC f e to
quickly navigate between `Emacs` and `Spacemacs` specific files.
Key Binding | Description
------------------------------------------|----------------------------------------------------------------
SPC f e c | open `ido` in the `contrib` folder
SPC f e d | open the spacemacs dotfile (`~/.spacemacs`)
SPC f e h | discover `Spacemacs` layers and packages using `helm`
SPC f e i | open the all mighty `init.el`
SPC f e s | open `ido` in the `spacemacs` layer folder
### Ido
`Spacemacs` displays the `ido` minibuffer vertically thanks to the
[ido-vertical-mode][ido-vertical-mode].
Basic `ido` operations can be done with `Ctrl` key:
Key Binding | Description
-----------------------|----------------------------------------------------------------
C- | open a `dired buffer`
C-b | open selected file in a horizontally split window
C-d | delete selected file (ask for confirmation)
C-h | go to parent directory
C-j | select next file or directory
C-S-j | go to next directory
C-k | select previous file or directory
C-S-k | go to previous directory
C-l | open the selected file
C-n | next history element
C-p | previous history element
C-t | open selected file in a new frame
C-v | open selected file in a vertically split window
C-x | open selected file in other window
#### Experimental Ido feature
If `dotspacemacs-feature-toggle-leader-on-jk` is non nil, pressing `jk` while
in `ido` minibuffer will trigger the evil leader.
When evil leader is triggered the following commands are available:
Key Binding | Description
--------------|----------------------------------------------------------------
b | open selected file in a horizontally split window
t | open selected file in a new frame
v | open selected file in a vertically split window
x | open selected file in other window
### NeoTree file tree
`Spacemacs` provides a quick and simple way to navigate in an unknown project
file tree with [NeoTree][neotree].
To toggle the `NeoTree` buffer press:
f t
The NeoTree window always has the number `0` so it does not shift the current
number of the other windows. To select the NeoTree window you then use
SPC 0.
#### NeoTree navigation
Navigation is centered on the `hjkl` with the hope to provide a fast navigation
experience like in [ranger][]:
Key Binding | Description
---------------------------------|----------------------------------------------------------------
h | collapse expanded directory or go to parent node
H | previous sibling
j | next file or directory
J | next expanded directory on level down
k | previous file or directory
K | parent directory, when reaching the root change it to parent directory
l or RET | expand directory
L | next sibling
**Note:** The point is automatically set to the first letter of a node for a
smoother experience.
#### Opening files with NeoTree
By default a file is opened in the last active window. It is possible to choose
window number where to open a file by using a numeric argument, for instance
2 l or 2 RET will open the current file in the windows 2.
It is also possible to open the file in a split window with | and
-:
Key Binding | Description
----------------------------------|----------------------------------------------------------------
l or RET | open file in last active window
# l or 2 RET| open file in window number `#`
| | open file in an vertically split window
- | open file in an horizontally split window
#### Other NeoTree key bindings
Key Binding | Description
---------------------------------|----------------------------------------------------------------
TAB | toggle stretching of the buffer
c | create a node
d | delete a node
g | refresh
s | toggle showing of hidden files
q or fd | hide `NeoTree` buffer
r | rename a node
#### NeoTree mode-line
The mode-line has the following format `[x/y] d (D:a, F:b)` where:
- `x` is the index of the current selected file or directory
- `y` the total number of items (file and directory) in the current directory
- `d` the name of the current directory
- `a` the number of directories in the current directory
- `b` the number of files in the current directory
### Shells
#### Key bindings
Key Binding | Description
--------------------|----------------------------------------------------------------
C-j | next item in history
C-k | previous item in history
SPC m h | browse history with `helm` (works in `eshell` and `shell`)
#### Staying in insert state
Navigating in shell buffers can be tricky because it is not possible to use the
leader in `insert state`. Switching back and forth between normal and insert
states can be tedious.
There are two solutions for this:
- use C-o then use the leader key
- enable the [leader on `jk`](#experimental-insert-state-feature)
experimental feature.
### Bookmarks
Bookmarks can be set anywhere in a file. Bookmarks are persistent. They are very
useful to jump to/open a known project. `Spacemacs` used `helm-bookmarks` to
manage them.
Open an `helm` window with the current bookmarks by pressing:
h b
Then in the `helm-bookmarks` buffer:
Key Binding | Description
-------------------|----------------------------------------------------------------
CTRL+d | delete the selected bookmark
CTRL+e | edit the selected bookmark
CTRL+f | toggle filename location
CTRL+o | open the selected bookmark in another window
To save a new bookmark, just type the name of the bookmark and press `RET`.
## Searching
### Project Searching
Key Binding | Description
--------------------------------------|---------------------------------------------
SPC / or SPC a | with [The Silver Searcher][ag]
SPC A | with `ack`
SPC g | with `grep`
SPC h l | show last helm popup
### Persistent highlighting
`Spacemacs` uses `evil-search-highlight-persist` to keep the searched expression
highlighted until the next search. It is also possible to clear the
highlighting by pressing SPC s c or executing the ex command `:noh`.
### Stacking highlights
With [hl-anything][] it is possible to highlight all occurrences of the word
under point. The highlights can be stacked.
Key Binding | Description
-----------------------|----------------------------------------------------------------
SPC h c | clear the highlightings
SPC h g c | clear the highlightings globally (all opened buffers)
SPC h h | highlight all occurrence of the word at point
SPC h g h | highlight all occurrence of the word at point globally (all opened buffers)
SPC h n | next highlighted occurrence
SPC h N | previous highlighted occurrence
SPC h p | toggle auto-highlight of the enclosing parenthesis
SPC h r | restore saved highlights in the current buffer
SPC h s | save current highlights
### Highlight current symbol
`Spacemacs` supports highlighting of the current symbol on demand (provided by
the [auto-highlight-symbol][auto-highlight] mode) and add a micro-state to
easily navigate and rename this symbol.
It is also possible to change the range of the navigation on the fly to:
- buffer
- function
- visible area
To initiate the highlighting of the current symbol under point press
SPC s h.
Navigation between the highlighted symbols can be done with the commands:
Key Binding | Description
-----------------------|------------------------------------------------------------
* | initiate navigation micro-state
SPC s b | go to the last searched occurrence of the last highlighted symbol
SPC s e | edit all occurrences of the current symbol(*)
SPC s h | highlight the current symbol and all its occurrence within the current range
SPC s R | change range to default (`whole buffer`)
In 'Spacemacs' highlight symbol micro-state:
Key Binding | Description
--------------|------------------------------------------------------------
e | edit occurrences (*)
n | go to next occurrence
N | go to previous occurrence
d | go to next definition occurrence
D | go to previous definition occurrence
r | change range (`function`, `display area`, `whole buffer`)
R | go to home occurrence (reset position to starting occurrence)
Any other key | leave the navigation micro-state
(*) using [iedit][] or the default implementation of `auto-highlight-symbol`
The micro-state text in minibuffer display the following information:
[6/11]* press (n/N) to navigate, (e) to edit, (r) to change range or (R) for reset
Where ` [x/y]*` is:
- M: the current range mode
- ``: whole buffer range
- ``: current display range
- ``: current function range
- `x`: the index of the current highlighted occurrence
- `y`: the total number of occurrences
- `*`: appears if there is at least one occurrence which is not currently
visible.
### Visual Star
With [evil-visualstar][] you can search for the next occurrence of the current
selection.
It is pretty useful combined with the [expand-region](#region-selection)
bindings.
_Note:_ If the current state is not the `visual state` then pressing `*` uses
[auto-highlight-symbol](#auto-highlight-symbols) and its micro-state.
### Listing symbols by semantic
Use `helm-semantic-or-imenu` command from `Helm` to quickly navigate between
the symbols in a buffer.
To list all the symbols of a buffer press:
s l
### Helm-swoop
This is very similar to `moccur`, it displays a `helm` buffer with all the
occurrences of the word under point. You can then change the search query
in real-time and navigate between them easily.
You can even edit the occurrences directly in the `helm` buffer and apply
the modifications to the buffer.
Key Binding | Description
-----------------------|----------------------------------------------------------------
SPC s s | execute `helm-swoop`
SPC s S | execute `helm-multi-swoop`
SPC s C-s | execute `helm-multi-swoop-all`
## Editing
### Text manipulation commands
Text related commands (start with `x`):
Key Binding | Description
-----------------------|------------------------------------------------------------
SPC x u | set the selected text to lower case
SPC x U | set the selected text to upper case
SPC x d w | delete trailing whitespaces
SPC x g l | set languages used by translate commands
SPC x g t | translate current word using Google Translate
SPC x g T | reverse source and target languages
SPC x m j | move down a line of text
SPC x m k | move up a line of text
SPC x t c | swap (transpose) the current character with the previous one
SPC x t w | swap (transpose) the current word with the previous one
SPC x t l | swap (transpose) the current line with the previous one
SPC x w c | count the number of words in the selection region
SPC x w C | count the number of occurrences per word in the select region
### Smartparens Strict mode
[Smartparens][sp] comes with a strict mode which prevents deletion of
parenthesis if the result is unbalanced.
This mode can be frustrating for novices, this is why it is not enabled by
default.
It is possible to enable it easily for _all programming modes_ with the
variable `dotspacemacs-smartparens-strict-mode` of you `~/.spacemacs`.
```elisp
(setq-default dotspacemacs-smartparens-strict-mode t)
```
### Zooming
#### Text
The font size of the current buffer can be adjusted with the commands:
Key Binding | Description
-----------------------|------------------------------------------------------------
SPC z x + | scale up the font and initiate the font scaling micro-state
SPC z x - | scale down the font and initiate the font scaling micro-state
SPC z x = | reset the font size (no scaling) and initiate the font scaling micro-state
+ | increase the font size
- | decrease the font size
= | reset the font size
Any other key | leave the font scaling micro-state
Note that _only_ the text of the current buffer is scaled, the other buffers,
the mode-line and the minibuffer are not affected. To zoom the whole content of
a frame use the `zoom frame` bindings (see next section).
#### Frame
You can zoom in and out the whole content of the frame with the commands:
Key Binding | Description
-----------------------|------------------------------------------------------------
SPC z f + | zoom in the frame content
SPC z f - | zoom out the frame content
SPC z f = | reset the frame content size
+ | zoom in
- | zoom out
= | reset zoom
Any other key | leave the zoom frame micro-state
### Increase/Decrease numbers
`Spacemacs` uses [evil-numbers][] to easily increase or increase numbers.
Key Binding | Description
-----------------------|------------------------------------------------------------
SPC n + | increase the number under point by one and initiate micro-state
SPC n - | decrease the number under point by one and initiate micro-state
In micro-state:
Key Binding | Description
--------------|------------------------------------------------------------
+ | increase the number under point by one
- | decrease the number under point by one
Any other key | leave the micro-state
**Tips:** you can increase or decrease a value by more that once by using a
prefix argument (ie. `10 SPC n +` will add 10 to the number under point).
### Spell checking
Spell checking commands start with `S`:
Key Binding | Description
---------------------|------------------------------------------------------------
SPC S c | list of corrections in a `helm` buffer
SPC S d | change dictionary language
SPC S n | go to the next spell check error
### Region selection
Vi `Visual` modes are all supported by `evil`.
#### Expand-region
`Spacemacs` adds another `Visual` mode via the [expand-region][] mode.
Key Binding | Description
-------------------|----------------------------------------------------------------
SPC v | initiate expand-region mode then...
v | expand the region by one semantic unit
V | contract the region by one semantic unit
r | reset the region to initial selection
ESC | leave expand-region mode
#### Indent text object
With [evil-indent-textobject] the following action can be performed in
`normal state`:
- ii - Inner Indentation: the surrounding textblock with the same
indentation
- ai - Above and Indentation: ii + the line above with a different
indentation
- aI - Above and Indentation+: ai + the line below with a different
indentation
Example (`|` is the point):
```elisp
(while (not done)
(messa|ge "All work and no play makes Jack a dull boy."))
(1+ 41)
```
- vii will select the line with message
- vai will select the whole while loop
- vaI will select the whole fragment
### Region narrowing
The displayed text of a buffer can be narrowed with the commands
(start with `n`):
Key Binding | Description
-----------------------|----------------------------------------------------------------
SPC n f | narrow the buffer to the current function
SPC n p | narrow the buffer to the visible page
SPC n r | narrow the buffer to the selected text
SPC n w | widen, i.e show the whole buffer again
### Line formatting
`Spacemacs` performs `go to the line below point and indent it` with
SPC j k.
You may repeat this operation with `evil-repeat` if you need to indent many lines.
Line formatting commands start with `j`:
Key Binding | Description
---------------------------|------------------------------------------------------------
J | join the current line with the next line
SPC j j | same as SPC j k but will split the current line at point
SPC J | split a quoted string or s-expression in place
SPC j J | split a quoted string or s-expression and auto-indent
SPC j k | go to next line and indent it using auto-indent rules
Used together these key bindings are very powerful to quickly reformat the code.
### Auto-completion
`Spacemacs` uses [auto-complete][] auto-completion engine.
Key Binding | Description
-------------------|------------------------------------------------------------
C-j | select next candidate
C-k | select previous candidate
TAB | expand selection or select next candidate
S-TAB | select previous candidate
return | complete word, if word is already completed insert a carriage return
### Replacing text with iedit
`Spacemacs` uses the powerful [iedit][] mode through [evil-iedit-state][] to
quickly edit multiple occurrences of a symbol or selection.
`evil-iedit-state` defines two new evil states:
- `iedit state`
- `iedit-insert state`
The color code for these states is `red`.
`evil-iedit-state` has also a nice integration with [expand-region][] for quick
edition of the current selected text by pressing e.
#### iedit states key bindings
##### State transitions
Key Binding | From | To
-------------------|:------------------:|:-------------------------:
SPC s e | normal or visual | iedit
e | expand-region | iedit
ESC | iedit | normal
C-g | iedit | normal
fd | iedit | normal
ESC | iedit-insert | iedit
C-g | iedit-insert | normal
fd | iedit-insert | normal
To sum-up, in `iedit-insert state` you have to press ESC twice to
go back to the `normal state`. You can also at any time press C-g
or fd to return to `normal state`.
**Note:** evil commands which switch to `insert state` will switch in
`iedit-insert state`.
##### In iedit state
`iedit state` inherits from `normal state`, the following key bindings are
specific to `iedit state`.
Key Binding | Description
------------------|------------------------------------------------------------
ESC | go back to `normal state`
TAB | toggle current occurrence
0 | go to the beginning of the current occurrence
$ | go to the end of the current occurrence
# | prefix all occurrences with an increasing number (SPC u to choose the starting number).
A | go to the end of the current occurrence and switch to `iedit-insert state`
D | delete the occurrences
F | restrict the scope to the function
gg | go to first occurrence
G | go to last occurrence
I | go to the beginning of the current occurrence and switch to `iedit-insert state`
J | increase the edition scope by one line below
K | increase the edition scope by one line above
L | restrict the scope to the current line
n | go to next occurrence
N | go to previous occurrence
p | replace occurrences with last yanked (copied) text
S | (substitute) delete the occurrences and switch to `iedit-insert state`
V | toggle visibility of lines with no occurrence
U | Up-case the occurrences
C-U | down-case the occurrences
**Note:** 0, $, A and I have the
default Vim behavior when used outside of an occurrence.
##### In iedit-insert state
Key Binding | Description
---------------------------|------------------------------------------------------------
ESC | go back to `iedit state`
C-g | go back to `normal state`
#### Examples
- manual selection of several words then replace: v w w SPC s e S "toto" ESC ESC
- append text to a word on two lines: v i w SPC s e J i "toto" ESC ESC
- substitute symbol _with expand-region_: SPC v v e S "toto" ESC ESC
- replace symbol with yanked (copied) text _with expand region_: SPC v e p ESC ESC
### Commenting
Comments are handled by [evil-nerd-commenter][], it's bound to the following keys.
Key Binding | Description
---------------------|------------------------------------------------------------
SPC ; | comment operator
SPC c i | comment invert
SPC c l | comment lines
SPC c p | comment paragraphs
SPC c r | comment region
SPC c t | comment to line
SPC c y | comment and yank
**Tips:** To comment efficiently a block of line use the combo:
; l
### Deleting files
Deletion is configured to send deleted files to system trash.
On OS X the `trash` program is required. It can be installed with
[homebrew][] with the following command:
```sh
$ brew install trash
```
To disable the trash you can set the variable `delete-by-moving-to-trash`
to `nil` in your `~/.spacemacs`.
### Editing Lisp code
Lisp navigation and edition is performed with a custom evil `lisp state`
provided by [evil-lisp-state][evil-lisp-state] package.
Intuitive navigation model:
`hjkl` behaves like in the default `normal state`.
**Next sexp on the same level (sibling)**
- L next sexp
- H previous sexp
**Change level (parent/children)**
- J go to next sexp one level down
- K go to previous one level up
And that's it! All these commands always put the point _at the beginning_ of
the sexp.
#### Key bindings maps
##### Regular normal state bindings
Key Binding | Function
----------------|------------------------------------------------------------
a | evil-append
c | evil-change
d | evil-delete
h | previous char
i | evil-insert-state
I | evil-insert-line
j | next visual line
k | previous visual line
l | next char
o | evil-insert-below
O | evil-insert-above
p | evil-past-after
P | evil-past-before
r | evil-replace
C-r | undo-tree-redo
u | undo-tree-undo
x | evil-delete-char
X | evil-delete-backward-char
y | evil-yank
ESC | evil-normal-state
##### Lisp specific bindings
_In this table we assume that `evil-lisp-state-backward-prefix` is set to
default ``_
Key Binding | Function
-----------------------|------------------------------------------------------------
( | insert sibling before sexp and switch to `insert state`
) | insert sibling after sexp and switch to `insert state`
$ | sp-end-of-sexp
0 | sp-beginning-of-sexp
A | sp-absorb-sexp
b | sp-forward-barf-sexp
b | sp-backward-barf-sexp
C | sp-convolute-sexp
Dd | sp-kill-hybrid-sexp
Dx | sp-kill-sexp
Dx | sp-backward-kill-sexp
Ds | sp-kill-symbol
Ds | sp-backward-kill-symbol
Dw | sp-kill-word
Dw | sp-backward-kill-word
E$ | evil-lisp-state-eval-sexp-end-of-line
Ee | eval-last-sexp
Ef | eval-defun
gs | go to source of symbol under point
gt | sp-transpose-sexp
gT | sp-transpose-hybrid-sexp
H | previous sexp at the same level
J | next sexp one level down
K | previous sexp one level up
L | next sexp of the same level
M | sp-join-sexp (think about `merge-sexp`)
R | sp-raise-sexp
s | sp-forward-slurp-sexp
s | sp-backward-slurp-sexp
S | sp-splice-sexp-killing-forward
S | sp-splice-sexp-killing-backward
w | wrap sexp
W | unwrap sexp
W | sp-backward-unwrap-sexp
Y | sp-copy-sexp
y | sp-backward-copy-sexp
backspace | sp-backward-delete-char
S-backspace | sp-delete-char
RET | indent next line
S-RET | insert new line char and switch to `insert state`
**Reminder:**
`lisp state` is a [base state](#base-states) which means that leaving
the `insert state` when the previous state was `lisp` will set you back
in `lisp state`.
To go back to `normal state` press `` or `fd` while in `lisp state`.
## Project management
Projects in `Spacemacs` are managed with [projectile][projectile]. In
`projectile` projects are defined implicitly, for instance the root of a
project is found when a `.git` repository or `.projectile` file is
encountered in the file tree.
`Helm` is used whenever it is possible.
To search in a project see [project searching](#project-searching).
`projectile` commands start with p:
Key Binding | Description
--------------------|------------------------------------------------------------
SPC p / | run `ag`
SPC p a | run `ag`
SPC p A | run `ack`
SPC p b | switch to project buffer
SPC p d | find directory
SPC p D | open project root in `dired`
SPC p f | find file
SPC p g | run `grep`
SPC p h | find file using `helm`
SPC p I | invalidate the projectile cache
SPC p j | find a tag
SPC p k | kill all project buffers
SPC p o | run `multi-occur`
SPC p R | regenerate the project's [e|g]tags
SPC p r | replace a string
SPC p s | switch project
SPC p t | find tags
SPC p T | find test files
SPC p v | open project root in `vc-dir` or `magit`
## Registers
Access commands to the various registers start with `r`:
Key Binding | Description
---------------------|------------------------------------------------------------
SPC r e | show evil yank and named registers
SPC r m | show marks register
SPC r r | show helm register
SPC r y | show kill ring
## Errors handling
`Spacemacs` uses [Flycheck][flycheck] to gives error feedback on the fly.
The checks are only performed at save time by default.
Errors management commands (star with `e`):
Key Binding | Description
---------------------|------------------------------------------------------------
SPC e c | clear all errors
SPC e f | toggle flycheck
SPC e l | display the `flycheck` list of errors/warnings
SPC e n | go to the next error
SPC e p | go to the previous error
Custom fringe bitmaps:
Symbol | Description
:----------------------------------:|------------
![dot-error](img/dot-error.png) | Error
![dot-warning](img/dot-warning.png) | warning
![dot-info](img/dot-info.png) | Info
## Compiling
`Spacemacs` binds a few commands to support compiling a project.
Key Binding | Description
---------------------|------------------------------------------------------------
SPC c c | use `helm-make` via projectile
SPC c C | compile
SPC c r | recompile
## Modes
### Major Mode leader key
Key bindings specific to the current `major mode` start with SPC m.
For convenience a shortcut key called the major mode leader key is set by
default on , which saves one precious keystroke.
It is possible to change the major mode leader key by defining the variable
`dotspacemacs-major-mode-leader-key` in your `~/.spacemacs`. For example to
setup the key on tabulation:
```elisp
(setq-default dotspacemacs-major-mode-leader-key "")
```
### Helm
`Spacemacs` add `hjkl` navigation to `helm` buffers:
Key Binding | Description
------------------|------------------------------------------------------------
CTRL+h | go to previous page
CTRL+j | go to previous item
CTRL+k | go to next item
CTRL+l | go to next page
#### Experimental Helm feature
If `dotspacemacs-feature-toggle-leader-on-jk` is non nil, pressing `jk` while
in `helm` buffer will trigger the evil leader.
When evil leader is triggered the following commands are available:
Key Binding | Description
--------------|----------------------------------------------------------------
1 | execute action 0
2 | execute action 1
3 | execute action 2
4 | execute action 3
5 | execute action 4
6 | execute action 5
7 | execute action 6
8 | execute action 7
9 | execute action 8
0 | execute action 9
a | toggle action selection menu
### Ledger
Key Binding | Description
-------------------|------------------------------------------------------------
SPC m a | add a transaction
SPC m d | delete current transaction
### Org
In `org`, [evil-org-mode][] is activated.
Key Binding | Description
----------------------|------------------------------------------------------------
SPC m a | org-agenda
SPC m A | org-archive-subtree
SPC m c | org-capture
SPC m C | evil-org-recompute-clocks
SPC m d | org-deadline
SPC m e | org-export-dispatch
SPC m i | org-clock-in
SPC m l | evil-org-open-links
SPC m m | org-ctrl-c-ctrl-c
SPC m o | org-clock-out
SPC m r | org-refile
SPC m s | org-schedule
SPC m t | org-show-todo-tree
gh | outline-up-heading
gj | org-forward-heading-same-level
gk | org-backward-heading-same-level
gl | outline-next-visible-heading
t | org-todo
T | org-insert-todo-heading nil
H | org-beginning-of-line
L | org-end-of-line
o | always-insert-item
O | org-insert-heading
$ | org-end-of-line
^ | org-beginning-of-line
< | org-metaleft
> | org-metaright
TAB | org-cycle
M-l | org-metaright
M-h | org-metaleft
M-k | org-metaup
M-j | org-metadown
M-L | org-shiftmetaright
M-H | org-shiftmetaleft
M-K | org-shiftmetaup
M-J | org-shiftmetadown
M-o | org-insert-heading+org-metaright
M-t | org-insert-todo-heading nil+ org-metaright
### Python
Writing python code with spacemacs is supported by python contribution. Please see
[python contribution][python-contrib] documentation for detail.
### JavaScript
More featured JavaScript support is provided by the javascript contribution. Please see
[javascript contribution][javascript-contrib] documentation for detail.
### rcirc
Key Binding | Description
------------------|------------------------------------------------------------
CTRL+j | next item in command history
CTRL+k | previous item in command history
### HTML and CSS
HTML contribution provides support for editing HTML, CSS, Scss and Less files. Please see
[html contribution][html-contrib] documentation for detail.
# Emacs Server
`Spacemacs` starts a server at launch. This server is killed whenever you close
your Emacs windows.
## Connecting to the Emacs server
TODO
## Keeping the server alive
It is possible to keep the server alive when you close Emacs by setting the
variable `dotspacemacs-persistent-server` to `t` in your `~./spacemacs`.
```elisp
(setq-default dotspacemacs-persistent-server t)
```
When this variable is set to `t`, the only way to quit Emacs _and_ kill the
server is to use the following bindings:
Key Binding | Description
-------------------|------------------------------------------------------------
SPC q q | Quit Emacs and kill the server
SPC q s | Save the buffers, quit Emacs and kill the server
## Troubleshoot
### Loading fails
If during the first boot of Emacs nothing seems to happen or if the
installation seems to abort prematurely, you can check for an error message
by opening the `*Warning*` buffer:
C-x b warning RET
_('C-x b' means 'Ctrl + x then b' and 'RET' means 'return')_
Then you can copy/paste the error in a [Github issue][issues], thank you.
### I have no file ~/.spacemacs
You have to manually copy the `~/.emacs.d/core/templates/.spacemacs.template`
file to `~/.spacemacs`
# Tips
## evil-lisp-state as default state
To Make `lisp state` the default state in `Emacs Lisp` buffers, insert in
your `~/.spacemacs` the following snippet:
```elisp
(defun dotspacemacs/config ()
(add-hook 'emacs-lisp-mode-hook 'evil-lisp-state))
```
## "jk" to trigger evil leader
It is possible to activate an experimental feature which allows to trigger the
evil leader in `insert state`, in `ido` minibuffer and in `helm` buffers.
To activate it, set `dotspacemacs-feature-toggle-leader-on-jk` to `t`.
```elisp
(setq-default dotspacemacs-feature-toggle-leader-on-jk t)
```
More info on this feature:
- [insert state](#experimental-insert-state-feature)
- [helm](#experimental-helm-feature)
- [ido](#experimental-ido-feature)
# Achievements
Achievements | Account
-----------------------------------------------------|------------------------
[First contribution][1st-contrib] | [trishume][]
[First contribution layer][1st-clayer] | [trishume][]
[First blog article on Spacemacs][1st-article] | [Wolfy87][]
[First contributed banner][1st-cbanner] | [chrisbarrett][]
[100th issue (PR)][100th-issue] | [danielwuz][]
[200th issue (question)][200th-issue] | [justrajdeep][]
[300th issue (PR)][300th-issue] | [danielwuz][]
[100th pull request][100th-PR] | [bru][]
PR gunner (8 PRs in a row) | [ralesi][]
100th star | [Jackneill][]
200th star | [jb55][]
400th star | [dbohdan][]
# Thank you
[Jokes aside](#using-configuration-layers), thank you Richard for this great
piece of software.
Thank you to all the contributors and the whole Emacs community from core
developers to elisp hackers!
[evil]: https://gitorious.org/evil/pages/Home
[evil-leader]: https://github.com/cofi/evil-leader
[RSI]: http://en.wikipedia.org/wiki/Repetitive_strain_injury
[sacha_guide]: http://sachachua.com/blog/2013/05/how-to-learn-emacs-a-hand-drawn-one-pager-for-beginners/
[use-package]: https://github.com/jwiegley/use-package
[keychords]: http://www.emacswiki.org/emacs/KeyChord
[centered-cursor]: http://www.emacswiki.org/emacs/centered-cursor-mode.el
[ace-jump]: https://github.com/winterTTr/ace-jump-mode
[helm]: https://github.com/emacs-helm/helm
[popwin]: http://www.emacswiki.org/emacs/PopWin
[golden-ratio]: https://github.com/roman/golden-ratio.el
[solarized-theme]: https://github.com/bbatsov/solarized-emacs
[powerline]: https://github.com/milkypostman/powerline
[diminish]: http://www.emacswiki.org/emacs/DiminishedModes
[auto-complete]: https://github.com/auto-complete
[auto-highlight]: https://github.com/emacsmirror/auto-highlight-symbol
[e-project]: https://github.com/jrockway/eproject
[projectile]: https://github.com/bbatsov/projectile
[sp]: https://github.com/Fuco1/smartparens
[ag]: https://github.com/ggreer/the_silver_searcher
[flycheck]: https://github.com/flycheck
[yasnippet]: https://github.com/capitaomorte/yasnippet
[expand-region]: https://github.com/magnars/expand-region.el
[multiple-cursors]: https://github.com/magnars/multiple-cursors.el
[keybindings]: https://github.com/syl20bnr/vimacs/blob/master/my-keybindings.el
[hswoop]: https://github.com/ShingoFukuyama/helm-swoop
[hcss]: https://github.com/ShingoFukuyama/helm-css-scss
[hyas]: https://github.com/emacs-helm/helm-c-yasnippet
[hthemes]: https://github.com/syohex/emacs-helm-themes
[projectile]: https://github.com/bbatsov/projectile
[hdescbinds]: https://github.com/emacs-helm/helm-descbinds
[hflyspell]: https://gist.github.com/cofi/3013327
[iedit]: https://github.com/tsdh/iedit
[evil-iedit-state]: https://github.com/syl20bnr/evil-iedit-state
[evil-indent-textobject]: https://github.com/cofi/evil-indent-textobject
[evil-visualstar]: https://github.com/bling/evil-visualstar
[evil-exchange]: https://github.com/Dewdrops/evil-exchange
[evil-surround]: https://github.com/timcharper/evil-surround
[camelcasemotion.vim]: http://www.vim.org/scripts/script.php?script_id=1905
[vim-exchange]: https://github.com/tommcdo/vim-exchange
[vim-surround]: https://github.com/tpope/vim-surround
[evil-nerd-commenter]: https://github.com/redguardtoo/evil-nerd-commenter
[nerdcommenter]: https://github.com/scrooloose/nerdcommenter
[source code pro]: https://github.com/adobe-fonts/source-code-pro
[evil-escape]: https://github.com/syl20bnr/evil-escape
[evil-args]: https://github.com/wcsmith/evil-args
[evil-jumper]: https://github.com/bling/evil-jumper
[evil-numbers]: https://github.com/cofi/evil-numbers
[evil-org-mode]: https://github.com/edwtjo/evil-org-mode
[evil-lisp-state]: https://github.com/syl20bnr/evil-lisp-state
[git-gutter]: https://github.com/syohex/emacs-git-gutter-fringe
[nose]: https://github.com/nose-devs/nose/
[nose.el]: https://github.com/syl20bnr/nose.el
[pylookup]: https://github.com/tsgates/pylookup
[jedi]: https://github.com/tkf/emacs-jedi
[ess-R-object-popup]: https://github.com/myuhe/ess-R-object-popup.el
[ess-R-data-view]: https://github.com/myuhe/ess-R-data-view.el
[leuven-theme]: https://github.com/fniessen/emacs-leuven-theme
[monokai-theme]: https://github.com/oneKelvinSmith/monokai-emacs
[zenburn-theme]: https://github.com/bbatsov/zenburn-emacs
[ido-vertical-mode]: https://github.com/gempesaw/ido-vertical-mode.el
[issues]: https://github.com/syl20bnr/spacemacs/issues
[vundle]: https://github.com/gmarik/Vundle.vim
[anzu]: https://github.com/syohex/emacs-anzu
[javascript-contrib]: https://github.com/syl20bnr/spacemacs/tree/master/contrib/lang/javascript
[themes-megapack]: https://github.com/syl20bnr/spacemacs/tree/master/contrib/themes-megapack
[python-contrib]: https://github.com/syl20bnr/spacemacs/tree/master/contrib/lang/python
[html-contrib]: https://github.com/syl20bnr/spacemacs/tree/master/contrib/lang/html
[guide-key]: https://github.com/kai2nenobu/guide-key
[guide-key-tip]: https://github.com/aki2o/guide-key-tip
[gitter]: https://gitter.im/syl20bnr/spacemacs
[CONTRIBUTE.md]: https://github.com/syl20bnr/spacemacs/blob/master/doc/CONTRIBUTE.md
[neotree]: https://github.com/jaypei/emacs-neotree
[nerdtree]: https://github.com/scrooloose/nerdtree
[anaconda-mode]: https://github.com/proofit404/anaconda-mode
[1st-contrib]: https://github.com/syl20bnr/spacemacs/pull/19
[1st-clayer]: https://github.com/syl20bnr/spacemacs/commit/e802027d75d0c0aed55539b0da2dfa0df94dfd39
[1st-article]: http://oli.me.uk/2014/11/06/spacemacs-emacs-vim/
[1st-cbanner]: https://github.com/syl20bnr/spacemacs/commit/7b44a56263049482ed540ed6815a295633ffe9d1
[100th-issue]: https://github.com/syl20bnr/spacemacs/pull/100
[200th-issue]: https://github.com/syl20bnr/spacemacs/pull/200
[300th-issue]: https://github.com/syl20bnr/spacemacs/pull/300
[100th-PR]: https://github.com/syl20bnr/spacemacs/pull/228
[trishume]:https://github.com/trishume
[Wolfy87]:https://github.com/Wolfy87
[danielwuz]:https://github.com/danielwuz
[chrisbarrett]:https://github.com/chrisbarrett
[justrajdeep]:https://github.com/justrajdeep
[dbohdan]:https://github.com/dbohdan
[bru]:https://github.com/bru
[ralesi]:https://github.com/ralesi
[Jackneill]:https://github.com/Jackneill
[jb55]:https://github.com/jb55
[use-package]: https://github.com/jwiegley/use-package
[Paradox]: https://github.com/Bruce-Connor/paradox
[fancy-battery]: https://github.com/lunaryorn/fancy-battery.el
[MacType]: https://code.google.com/p/mactype/