This is my personal Emacs configuration. At first it was based on Purcell’s and Chen Bin’s Emacs configuration. Then I kept stealing codes and ideas from others to make it state of the art.
To install, clone this repo to ~/.emacs.d
. Please backup your old
~/.emacs
and ~/.emacs.d
first
git clone https://github.com/zhengfaxiang/emacs.d.git ~/.emacs.d
Then just fire up your Emacs, further third-party packages will be automatically downloaded and installed.
Update this config by entering ~/.emacs.d
and typing git pull
. You
also need to update the third-party packages by:
M-x package-list-packages
, then U
followed by x
.
For fully enjoying the powerfull features of this configuration, there’s some recommended instructions:
Fantasque Sans Mono
is used by default. You can change it to whatever you like on
lisp/init-fonts.el
.
I personally use TUNA for faster package installing and updating. If you find
it slow, you may modify the package-archeves
variable on lisp/init-elpa.el
.
flyspell
is used for automatic spell checking- Install
aspell
&aspell-en
orhunspell
&hunspell-en
through your system package manager - you can easily
C-.
to correct a word usingflyspell-correct-ivy
- emacs-jedi is used for auto completion. Install
jedi
,service_factory
bypip
or system package manager. - Install
flake8
,pylint
bypip
or system package manager for syntax checking with flycheck. - Don’t forget
M-x jedi:install-server
before using python-mode - If you’re coding with multiple versions of Python, install
virtualenv through
pip install
. After modified your virtualenv, useM-x pyvenv-activate
to activate it.
- irony-mode is used to improve the editing experience for the C, C++ and Object-C languages.
- Install libclang and cmake through your system package manager
M-x irony-install-server
to installirony-server
Ripgrep is required by counsel-rg
for nice code searching experience.
Emacs support IDL with its embedded IDLWave-mode
and IDLWave-shell
. If
you are using IDL version 7.1, then you may have to do something within
your terminal to fix a warning:
sudo mkdir /usr/local/itt/idl71/help/online_help
sudo ln -s /usr/local/itt/idl71/help/idl_catalog.xml \
/usr/local/itt/idl71/help/online_help/
sudo ln -s /usr/local/itt/idl71/help/idlithelp.xml \
/usr/local/itt/idl71/help/online_help/
sudo ln -s /usr/local/itt/idl71/help/template_help.xml \
/usr/local/itt/idl71/help/online_help/
then open your Emacs and M-x idl-rescan-asynchronously
.
If using Emacs inside the Terminal, C-c a
and C-c y
can help you
interact with the system clipboard. Note that xsel is required on
gnu/linux.
Ivy is a completion method that’s similar to Ido
, but with emphasis on
simplicity and customizability.
Keybinding | Command |
---|---|
C-x C-f | counsel-find-file |
M-y | counsel-yank-pop |
C-s | swiper |
C-c i a | counsel-rg |
C-c i u | counsel-unicode-char |
C-c i l | counsel-locate |
C-c i j | counsel-file-jump |
C-c i g | counsel-git |
C-c i k | counsel-git-grep |
C-c i t | counsel-load-theme |
C-c i f | counsel-recentf |
C-c i m | counsel-mark-ring |
C-h v | counsel-describe-variable |
C-h S | counsel-info-lookup-symbol |
C-h f | counsel-describe-function |
C-h k | counsel-descbinds |
C-h a | counsel-apropos |
C-h b | counsel-bookmark |
C-c i i | ivy-imenu-anywhere |
C-c i r | ivy-resume |
Smex is a M-x enhancement for Emacs which provides a convenient interface to your recently and most frequently used commands. It works with ivy just fine.
Avy is for jumping to visible text using a char-based decision tree.
Keybinding | Command |
---|---|
M-s SPC | avy-goto-word-or-subword-1 |
M-s s | avy-goto-char |
M-s l | avy-goto-line |
M-s m | avy-pop-mark |
M-s o | fx/avy-open-url |
Company-mode is used for auto-completion. C-h
to abort completion may be
helpful.
Yasnippet is a template system for Emacs. Amazing and easy to extend.
Magit is used for magical Git integration.
Keybinding | Command |
---|---|
C-x g s | magit-status |
C-x g l | magit-log-buffer-file |
C-x g S | magit-stage-file |
C-x g U | magit-unstage-file |
Projectile is for efficient project management. Jumping between projects,
finding file in a project, etc, do what you want. C-x p
and you will see
a popup window by which-key with a series of keybindings about projectile
.
Multiple-cursors gives you multi-cursor editing experience.
Keybinding | Command |
---|---|
C-c m c | mc/edit-lines |
C-c m e | mc/edit-ends-of-lines |
C-c m a | mc/edit-beginnings-of-lines |
C-c m r | set-rectangular-region-anchor |
C-S-<mouse-1> | mc/add-cursor-on-click |
C-> | mc/mark-next-like-this |
C-< | mc/mark-previous-like-this |
C-c C-< | mc/mark-all-like-this |
Anzu provides a minor mode which displays current match and total matches information in the mode-line in various search modes.
Keybinding | Command |
---|---|
M-% | anzu-query-replace |
C-M-% | anzu-query-replace-regexp |
Iedit allows you to edit one occurrence of some text in a buffer (possibly narrowed) or region, and simultaneously have other occurrences edited in the same way, with visual feedback as you type.
Keyboarding | Command |
---|---|
C-; | iedit-mode |
C-h C-; | iedit-mode-toggle-on-function |
C-x r <return> | iedit-rectangle-mode |
Visual-regexp is a regexp/replace command for Emacs with interactive visual feedback.
Keybinding | Command |
---|---|
C-c v r | vr/replace |
C-c v q | vr/query-replce |
C-c v m | vr/mc-mark |
Expand-region increases the selected region by semantic units.
Keybinding | Command |
---|---|
C-M-] | er/expand-region |
C-M-[ | er/contract-region |
Undo tree treats undo history as a branching tree of changes, which can be run
by C-x u
.
Highlight-symbol automatically highlights symbol at point. You can use M-p
and
M-n
to navigate between highlighted symbols, and also can use M-s r
to
apply query replace.
Smartparens is a minor mode for Emacs that deals with parens pairs and
tries to be smart about it. See lisp/init-smartparens.el
for keybindings.
HideShow hides and shows blocks of text.
Keybinding | Command |
---|---|
C-c z c | hs-hide-block |
C-c z o | hs-show-block |
C-c z C | hs-hide-all |
C-c z O | hs-show-all |
C-c z l | hs-hide-level |
C-c z z | hs-toggle-hiding |
C-c z <tab> | hs-toggle-hiding |
Winum uses M-1
through M-0
to navigate window.
Buffer-move is used for swapping buffers.
Keybinding | Command |
---|---|
C-x w <up> | buf-move-up |
C-x w <down> | buf-move-down |
C-x w <left> | buf-move-left |
C-x w <right> | buf-move-right |
Google-this is for launching google searches from within Emacs. C-x /
is
the prefix key.
Lorem Ipsum automatically generate dummy text.
Keybinding | Command |
---|---|
C-c l p | lorem-ipsum-insert-paragraphs |
C-c l s | lorem-ipsum-insert-sentences |
C-c l l | lorem-ipsum-insert-list |
Crux bundles a few useful interactive commands to enhance your overall Emacs experience. I use the following frequently:
Keybinding | Command |
---|---|
C-a | crux-move-beginning-of-line |
C-o | crux-smart-open-line |
C-S-o | crux-smart-open-line-above |
C-<backspace> | crux-kill-line-backwards |
C-S-<backspace> | crux-kill-whole-line |
C-x f o | crux-open-with |
C-x f r | crux-rename-file-and-buffer |
C-x f d | crux-delete-file-and-buffer |
C-x f s | crux-sudo-edit |
If you want to automatically reload the last session for every time
you open Emacs, you only need to M-x desktop-save
and hit <return>
key
for one time.
Goto-chg goes to the last place you made a change in the file.
Keybinding | Command |
---|---|
M-g l | goto-last-change |
M-g L | goto-last-change-reverse |
If you want to use shell within Emacs,
Keybinding | Command |
---|---|
C-x t e | shell-pop-eshell |
C-x t s | shell-pop-shell |
C-x t m | shell-pop-multiterm |
C-x t t | shell-pop-ansi-term |
C-x t T | shell-pop-term |
M-C-8
, M-C-9
and M-C-0
are used to adjust the opacity of Emacs
graphics window program.