Spacemacs
Table of Contents
Bookmarks
- Initiate with
SPC f b
Key Binding | Description |
---|---|
C-d | delete the selected bookmark |
C-e | edit the selected bookmark |
C-f | toggle filename location |
C-o | open the selected bookmark in another window |
Emacs
Indirect Buffers
An indirect buffer shares the text of some other buffer, which is called the base buffer of the indirect buffer. In some ways it is a buffer analogue of a symbolic link between files.
Regex
Emacs Regex engine specialties:
\ca ascii character
\Ca non-ascii character (newline included)
\cl latin character
\cg greek character
\s- whitespace character \s/ character quote character
\sw word constituent \s$ paired delimiter
\s_ symbol constituent \s' expression prefix
\s. punctuation character \s< comment starter
\s( open delimiter character \s> comment ender
\s) close delimiter character \s! generic comment delimiter
\s" string quote character \s| generic string delimiter
\s\ escape character
[-+[:digit:]] digit or + or - sign
\(\+\|-\)?[0-9]+\(\.[0-9]+\)? decimal number (-2 or 1.5 but not .2 or 1.)
\<\(\w+\) +\1\> two consecutive, identical words
\<[[:upper:]]\w* word starting with an uppercase letter
+$ trailing whitespaces (note the starting SPC)
\w\{20,\} word with 20 letters or more
\w+phony\> word ending by phony
\(19\|20\)[0-9]\{2\} year 1900-2099
^.\{6,\} at least 6 symbols
^[a-zA-Z0-9_]\{3,16\}$ decent string for a user name
<tag[^> C-q C-j ]*>\(.*?\)</tag> html tag
Tips
Searching
I want non-fuzzy searches sometimes. I tried to set dotspacemacs-helm-use-fuzzy
to nil
, but I couldn't recognize obvious changes. Instead, I found that escaping all whitespaces(use \_
, instaned of _
) seems to work as expected.
Save/Load layouts and workspaces
- Save
SPC l s
- Load
SPC l L
Layers
How :variables
in dotspacemacs-configuration-layers
works
- You can safely set variables for layers with
:variables
. - It will work like using
(setq-default)
.
auto-completion
YASnippet
Configuration
Organization
snippets |-- c-mode | |-- .yas-parents # contains "cc-mode text-mode" | `-- printf |-- cc-mode | |-- for | `-- while |-- java-mode | |-- .yas-parents # contains "cc-mode text-mode" | `-- println `-- text-mode |-- email `-- time
Writing
# name: mysnippet # key: my_ # -- ${1:$(make-string (string-width yas-text) ?\=)} ${1:Title} ${1:$(make-string (string-width yas-text) ?\=)} - (${1:id})${2:foo} { return $2; } - (void)set${2:$(capitalize yas-text)}:($1)aValue { [$2 autorelease]; $2 = [aValue retain]; } $0
- The lines above
# --
is meta $1
or${1}
is a tapstop${1:<something>}
for specifying a default value$0
is the exit point- A tapstop can show up multiple times, which mirrors the first occurance
- Mirrors can be transformed with
${2:$(elisp-code)
, withyas-text
place holder
- The lines above
csharp
SPC m s s
to start omnisharp- Select
*.sln
file on the project root for unity3d
restclient
- Lines starting with # are considered comments AND also act as separators.
SPC m s
to sendSPC m y
to copy as curl command
GET https://api.github.com
#
POST https://api.github.com
Content-Type: application/json
{
"key": "value"
}
ob-http
#+BEGIN_SRC http :pretty
GET https://api.github.com/repos/zweifisch/ob-http/languages
Accept: application/vnd.github.moondragon+json
#+END_SRC
#+RESULTS:
: {
: "Emacs Lisp": 8170
: }
Customization
Visual Pastes
Enable evil-visual pastes from system clipbaoard
Support multiple visual pastes. It's NOT recommended if you use cut and paste routine.
(defun evil-paste-after-from-0 ()
(interactive)
(let ((evil-this-register ?0))
(call-interactively 'evil-paste-after)))
(define-key evil-visual-state-map "p" 'evil-paste-after-from-0)
EditorConfig
It seems that Spacemacs
uses EditorConfig
implicitly. To make it explicit:
dotspacemacs-additional-packages '(editorconfig)
(defun dotspacemacs/user-config ()
(editorconfig-mode 1)
)
Use Cases
How to Fix 'Evaluation of code disabled'
- Simply run
:spacemacs/recompile-elpa
and restart emacs
How-to
Enable navigation by visual lines?
Add the following snippet to your dotspacemacs/user-config
function:
;; Make evil-mode up/down operate in screen lines instead of logical lines
(define-key evil-motion-state-map "j" 'evil-next-visual-line)
(define-key evil-motion-state-map "k" 'evil-previous-visual-line)
;; Also in visual mode
(define-key evil-visual-state-map "j" 'evil-next-visual-line)
(define-key evil-visual-state-map "k" 'evil-previous-visual-line)