10 Efficient Spacemacs Configurations

Source: Internet
Author: User

Using Emacs for some time, summed up their own practice of some of the quick configuration, I use the version is compiled by myself 24.5.

Quickly switch to the first buffer

Toggle Buffer C-x b ret is still a bit cumbersome, when I quickly edit between two buffers, I want an action to complete the switch, so I set shift+tab switch to the first buffer

(Global-set-key (kbd "<backtab>") # ' (Lambda () (interactive) (Switch-to-buffer (Other-buffer (current-buffer) 1))))
Recording and playback of keyboard macros

The default F3 is the recording macro, F4 is stop recording, c-x x playback macro

(Global-set-key (kbd "C-x x") ' Call-last-kbd-macro)
Automatically add spaces after commas
(Global-set-key (kbd ",") # ' (Lambda () (interactive) (INSERT, ")))
Copy the editing mode of the current row using Yasnippet

In most programming languages, the code for adjacent lines is very redundant, and the following C-c tab converts the current line into a temporary snippet template, which is very useful (dependent: yasnippet)

You can try it, edit go code is, in FMT. What is the effect of pressing c-c tab on PRINLN ("Hello World")

(defun spacemacs/wsk-yasnippet-current-line  ();;  C-c TAB   (interactive)    (let  (current-line  (string-trim-right  ( thing-at-point  ' Line t)))      (end-of-line)      ( newline-and-indent)      (yas-expand-snippet  (spacemacs// wsk-yasnippet-string-to-template  (String-trim current-line)))) (defun spacemacs// wsk-yasnippet-string-to-template  (String)    (let  (count 1))      ( labels  (rep  (text)                     (let  ((replace  (format  "${%d:%s}"  count text))                        (Incf count)                   &Nbsp;  replace))        (replace-regexp-in-string  "[a-za-z0-9]+"  # ' rep string)))        (global-set-key  (kbd  "C-c tab")   ' Spacemacs/wsk-yasnippet-current-line)
Show line numbers, brackets match, highlight brackets pair
;; Display line number (Global-linum-mode) (setq column-number-mode t);; Highlight bracket pairing (electric-pair-mode);; Highlight bracket Pairing (Show-paren-mode t) (setq show-paren-style ' parenthesis)
Undo-tree default Undo Once

Undo-tree is great, but most of the time we just need to undo once, you need to press C-x U P RET, the following bindings make Undo-tree default in the state of undo once C-x U RET, less press p. I feel like I should set a shortcut key for the undo once, but fortunately I do not use the undo many times.

(require  ' Undo-tree) (define-key undo-tree-map  (kbd  "C-x u")  # ' (lambda  ()                                                 (Interactive)                                                (Undo-tree-visualize)                                                (Undo-tree-visualize-undo)))
Speedbar

Frankly speaking, after Spacemacs built-in helm, I don't use speedbar anymore. Speedbar The problem is he created a buffer, and this buffer for C-x b is visible, I never want to switch to Speedbar buffer, so I wrote the following code, press F2 Toggle Speedbar Open State, and automatically refresh, When you don't want to show Speedbar, simply kill the buffer.

Note: I used the Sr-speedbar

(require  ' Sr-speedbar) (global-set-key  (kbd  "<f2>")   (lambda ()                                   (Interactive)                                   (Sr-speedbar-refresh)                                   (Sr-speedbar-toggle)                                  (unless   (SR-SPEEDBAR-EXIST-P)                                    (kill-buffer  "*speedbar*"))))

S key to search in Speedbar

(Require ' Speedbar) (Define-key Speedbar-mode-map (kbd "s") # ' (Lambda () (interactive) (Beginning-of-buffer) (Isearch-forward) )) (Define-key speedbar-mode-map (kbd "U") # ' (Lambda () (interactive) (speedbar-up-directory)))
Dot-spacemacs
Configure Elpa

Put the following code into the Spacemacs/init.

(Setq package-archives ' ("GNU". "Http://elpa.gnu.org/packages/") ("Marmalade"). "Https://marmalade-repo.org/packages/") ("Melpa"). "http://melpa.org/packages/")))
Jazz Color Theme

Jazz is a dark theme, Leuven is a bright version of the representative, the Org mode support surprisingly good, but poor performance under the Spacemacs. This code is in Set-default.

Dotspacemacs-themes ' (Jazz Solarized-dark Leuven s Olarized-light)
Font

I have a bit of font settings here, no way, playing games eye a bit of flowers, fonts need to find their own installation in the Spacemacs project, saying I also like Exvim, but since the Spacemacs, you understand.

   dotspacemacs-default-font  "(" Source code pro "                                :size  24                                :weight normal                                 :width normal                                 :p owerline-scale 1.1) 
Move the Private-layer out.

By default in the ~/.emacs.d/private directory, that is too silly, I do not move the source of Spacemacs, are to create their own init-package-layer

Configuration-layer-private-directory "~/dot-spacemacs/"
Set up a dedicated Yasnippet template

Default Spacemacs with a bunch of snippet templates, honestly I dare not press TAB, who knows what will come out, so I simply customize the snippet template path, all the templates are changed to uppercase, such as in the Golang FMT. PRINTLN, the template abbreviation is PLN. When all is changed to uppercase, there is a lot less error operation.

(Require ' Yasnippet)      (setq yas-snippet-dirs "~/dot-spacemacs/snippets")      (Yas-global-mode 1) (Yas-reload-all)
Org Mode

Frankly layman with Emacs first power should be org mode, but org mode range is very wide, highly recommended to see the official manual, the following is the official recommended settings, I think it is too great.

(Global-set-key "\c-cl" ' Org-store-link) (Global-set-key "\C-CC" ' Org-capture) (Global-set-key "\c-ca" ' Org-agenda) (Global-set-key "\C-CB" ' Org-iswitchb)

10 Efficient Spacemacs Configurations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.