2015-10-30 13:23:24 +00:00
#+TITLE : Quick start
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2017-05-22 14:16:12 +00:00
- [[#configuration-layers ][Configuration layers ]]
- [[#dotfile-spacemacs ][Dotfile (.spacemacs) ]]
- [[#dotdirectory-spacemacsd ][Dotdirectory (~/.spacemacs.d) ]]
- [[#learning-spacemacs ][Learning Spacemacs ]]
- [[#editing-styles ][Editing Styles ]]
- [[#the-leader-keys ][The leader keys ]]
- [[#evil-tutor ][Evil-tutor ]]
- [[#universal-argument ][Universal argument ]]
- [[#configuration-layers-and-package-discovery ][Configuration layers and Package discovery ]]
- [[#key-bindings-discovery ][Key bindings discovery ]]
- [[#describe-functions ][Describe functions ]]
- [[#how-tos ][How-To's ]]
2015-10-30 11:20:58 +00:00
* Configuration layers
2015-09-23 03:26:12 +00:00
Spacemacs divides its configuration into self-contained units called
2021-04-26 08:01:09 +00:00
=configuration layers= . These layers are stacked on top of each other to achieve
a custom configuration.
2015-09-23 03:26:12 +00:00
By default Spacemacs uses a dotfile called =~/.spacemacs= to control which
2021-04-26 08:01:09 +00:00
layers to load. Within this file you can also configure certain features. This
design makes it extremely easy to turn Spacemacs into a fully integrated
development environment.
For example to get python support, simply add =python= to the list of
=dotspacemacs-configuration-layers= in your =~/.spacemacs= . Find the
=~/.spacemacs= file by pressing =SPC f e d= and then after adding the layer,
reload it with =SPC f e R= . Now open a =.py= file (=SPC f f= ) to find the python
environment has been fully configured. Some extra configuration might make the
environment even more powerful, which is very well described in the [[https://develop.spacemacs.org/layers/ +lang/python/README.html][layer's
documentation]] that can be accessed by pressing =SPC h l= and selecting the
=python= layer entry. For configuration of specific packages within a layer,
=SPC h SPC= provides quick navigation functionality for jumping directly to the
relevant location within the configuration files.
A list of pre-configured layers is available [[https://develop.spacemacs.org/layers/LAYERS.html ][here ]]. If you still would like to
configure anything not covered by any layer, then it is easy to build a personal
layer.
2015-09-23 03:26:12 +00:00
A configuration layer is a directory containing at least a =packages.el=
file which defines and configures packages to be downloaded from Emacs
package repositories using the =package.el= built-in feature of Emacs.
If you already have your own =Emacs= configuration you can move it to your
own layer.
The following command creates a layer in the =private= directory:
2015-10-30 11:20:58 +00:00
#+BEGIN_EXAMPLE
2018-09-19 03:54:47 +00:00
SPC SPC configuration-layer/create-layer RET
2015-10-30 11:20:58 +00:00
#+END_EXAMPLE
2015-09-23 03:26:12 +00:00
Any configuration layers you create must be explicitly loaded in =~/.spacemacs= .
Note: For your privacy, the contents of the =private= directory are not
under source control. See the section on private configuration management in
2017-07-16 16:37:37 +00:00
the [[https://github.com/syl20bnr/spacemacs/blob/develop/doc/DOCUMENTATION.org ][documentation ]].
2015-09-23 03:26:12 +00:00
2015-10-30 11:20:58 +00:00
* Dotfile (.spacemacs)
2015-09-23 03:26:12 +00:00
As mentioned =.spacemacs= controls which configuration layers to load and
is also a means to customizing Spacemacs.
The following command will create a =.spacemacs= file in your home directory:
#+BEGIN_EXAMPLE
2018-09-19 03:54:47 +00:00
SPC SPC dotspacemacs/install RET
2015-09-23 03:26:12 +00:00
#+END_EXAMPLE
To open the installed dotfile:
#+BEGIN_EXAMPLE
2018-09-19 03:54:47 +00:00
SPC f e d
2015-09-23 03:26:12 +00:00
#+END_EXAMPLE
To load some configuration layers using the variable
=dotspacemacs-configuration-layers= :
#+BEGIN_SRC elisp
2018-09-19 03:54:47 +00:00
;; List of configuration layers to load.
dotspacemacs-configuration-layers '(auto-completion smex)
2015-09-23 03:26:12 +00:00
#+END_SRC
Some configuration layers support configuration variables to expose granular
2017-07-16 16:37:37 +00:00
control over layer-specific features, [[https://github.com/syl20bnr/spacemacs/blob/develop/layers/+source-control/git/README.org ][git layer ]] being one such example.
2015-09-23 03:26:12 +00:00
Variables can be directly set within =dotspacemacs-configuration-layers= like so:
#+BEGIN_SRC elisp
2018-09-19 03:54:47 +00:00
;; List of configuration layers to load.
dotspacemacs-configuration-layers '(auto-completion
(git :variables
git-magit-status-fullscreen t)
smex)
2015-09-23 03:26:12 +00:00
#+END_SRC
At anytime you can apply the changes made to the dotfile or layers
_without restarting_ Spacemacs by pressing ~SPC f e R~ .
2017-01-09 12:11:54 +00:00
The [[https://github.com/syl20bnr/spacemacs/blob/master/core/templates/.spacemacs.template ][dotfile template ]] contains further information about how to customize
2017-07-16 16:37:37 +00:00
Spacemacs. See the dotfile configuration section of the [[https://github.com/syl20bnr/spacemacs/blob/develop/doc/DOCUMENTATION.org#dotfile-configuration ][documentation ]] for
2015-09-23 03:26:12 +00:00
more details.
2015-10-30 11:20:58 +00:00
* Dotdirectory (~/.spacemacs.d)
2015-09-23 03:26:12 +00:00
Like =Emacs= , Spacemacs initialization can also be contained in an =init.el= file
in a special directory =~/.spacemacs.d= . The contents of the dotfile should be
then copied in the =init.el= file.
2016-04-17 16:43:47 +00:00
The Emacs dotfile or dotdirectory is not replaced but rather
complemented by the Spacemacs dotfile or dotdirectory. During startup,
Emacs still uses =~/.emacs.d/init.el= (or =~/.emacs= ) for its
initialization, and variable =user-emacs-directory= will still point
to =~/.emacs.d/= , even if =~/.spacemacs.d= or =~/.spacemacs= are
present. Only now =~/.emacs.d/init.el= is provided by Spacemacs
(e.g. after cloning the Spacemacs git repo into an empty
2017-04-20 13:43:10 +00:00
=~/.emacs.d/= ), and your own personal configurations go into
2016-04-17 16:43:47 +00:00
=~/.spacemacs.d/init.el= (or =~/.spacemacs= ).
Have a look into the FAQ for an easy workaround to maintain (your
former) vanilla Emacs and (your new) Spacemacs configurations
side-by-side without the need to rename and backup =~/.emacs.d/= .
2015-10-30 11:20:58 +00:00
* Learning Spacemacs
** Editing Styles
2015-09-23 03:26:12 +00:00
Spacemacs can be used by Vim users or Emacs users by setting the
=dotspacemacs-editing-style= variable to =vim= , =emacs= or even =hybrid=
in the dotfile =~/.spacemacs= .
2015-10-30 11:20:58 +00:00
** The leader keys
2015-10-12 23:12:09 +00:00
Spacemacs key bindings use a leader key which is by default bound to
2015-09-23 03:26:12 +00:00
~SPC~ (space bar) in =vim= or =hybrid= editing styles and ~M-m~ in =emacs=
style.
You can change it by setting the variable =dotspacemacs-leader-key= if
you use the =vim= style or =dotspacemacs-emacs-leader-key= if you use
the =emacs= style (these variables must be set in the file =~/.spacemacs= ).
For simplicity the documentation always refers to the leader key as
~SPC~ .
2017-04-20 13:43:10 +00:00
There is a secondary leader key called the major-mode leader key which is
2016-02-29 09:23:14 +00:00
set to ~ , ~ by default. This key is a shortcut for ~SPC m~
2015-09-23 03:26:12 +00:00
where all the major-mode specific commands are bound.
2015-10-30 11:20:58 +00:00
** Evil-tutor
2015-09-23 03:26:12 +00:00
If you are willing to learn the Vim key bindings (highly recommended since
2019-05-18 11:47:29 +00:00
you can benefit from them even in =emacs= style), press ~SPC h T v~
2015-09-23 03:26:12 +00:00
to begin an Evil-adapted Vimtutor.
2015-10-30 11:20:58 +00:00
** Universal argument
2015-09-23 03:26:12 +00:00
In =vim= editing style the universal argument defaults to ~SPC u~
instead of ~C-u~ because the latter is used to scroll up as in Vim.
2015-10-30 11:20:58 +00:00
** Configuration layers and Package discovery
2016-01-04 19:20:54 +00:00
By using =helm-spacemacs-help= with ~SPC h SPC~ you can quickly search
2015-09-23 03:26:12 +00:00
for a package and get the name of the layers using it.
You can also easily go to the =README.org= of a layer or go to the initialization
function of a package.
2015-10-30 11:20:58 +00:00
** Key bindings discovery
2015-09-23 03:26:12 +00:00
Thanks to [[https://github.com/justbur/emacs-which-key ][which-key ]], whenever a prefix command is pressed (like ~SPC~ )
a buffer appears after one second listing the possible keys for this prefix.
It is also possible to search for specific key bindings by pressing:
#+BEGIN_EXAMPLE
2018-09-19 03:54:47 +00:00
SPC ?
2015-09-23 03:26:12 +00:00
#+END_EXAMPLE
To narrow the bindings list to those prefixed with =SPC= ,
type a pattern like this regular expression:
#+BEGIN_EXAMPLE
2018-09-19 03:54:47 +00:00
SPC\ b
2015-09-23 03:26:12 +00:00
#+END_EXAMPLE
2016-02-25 19:33:05 +00:00
which would list all =buffer= related bindings. *Note:* You are at the
/HELM-Descbind/ prompt, the pattern consists of 6 letters: uppercase ~SPC~ , a
backslash, an actual space and a lowercase ~b~ .
2015-09-23 03:26:12 +00:00
2015-10-30 11:20:58 +00:00
** Describe functions
2015-09-23 03:26:12 +00:00
=Describe functions= are powerful Emacs introspection commands to get information
about functions, variables, modes etc. These commands are bound thusly:
2021-04-17 07:08:57 +00:00
| Key binding | Description |
|-------------+---------------------|
| ~SPC h d f~ | describe-function |
| ~SPC h d k~ | describe-key |
| ~SPC h d m~ | describe-mode |
| ~SPC h d v~ | describe-variable |
| ~SPC h d x~ | describe-ex-command |
2015-09-23 03:26:12 +00:00
2015-10-30 11:20:58 +00:00
* How-To's
2017-07-16 16:37:37 +00:00
Some quick =how-to's= are compiled in the [[https://github.com/syl20bnr/spacemacs/blob/develop/doc/FAQ.org#how-do-i ][FAQ. ]]