Skip to content
/ emacs.d Public

Emacs configuration supporting C/C++, Python, LaTeX, Matlab, etc

License

Notifications You must be signed in to change notification settings

fzh3g/emacs.d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Emacs configuration

Introduction

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.

Installation

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

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.

Before you start

For fully enjoying the powerfull features of this configuration, there’s some recommended instructions:

Fonts

Fantasque Sans Mono is used by default. You can change it to whatever you like on lisp/init-fonts.el.

Packages

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.

Spelling

  • flyspell is used for automatic spell checking
  • Install aspell & aspell-en or hunspell & hunspell-en through your system package manager
  • you can easily C-. to correct a word using flyspell-correct-ivy

Python

  • emacs-jedi is used for auto completion. Install jedi, service_factory by pip or system package manager.
  • Install flake8, pylint by pip 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, use M-x pyvenv-activate to activate it.

C/C++

  • 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 install irony-server

Ripgrep

Ripgrep is required by counsel-rg for nice code searching experience.

IDL (Interactive Data Language)

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.

More features

Copy/Paste

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

Ivy is a completion method that’s similar to Ido, but with emphasis on simplicity and customizability.

KeybindingCommand
C-x C-fcounsel-find-file
M-ycounsel-yank-pop
C-sswiper
C-c i acounsel-rg
C-c i ucounsel-unicode-char
C-c i lcounsel-locate
C-c i jcounsel-file-jump
C-c i gcounsel-git
C-c i kcounsel-git-grep
C-c i tcounsel-load-theme
C-c i fcounsel-recentf
C-c i mcounsel-mark-ring
C-h vcounsel-describe-variable
C-h Scounsel-info-lookup-symbol
C-h fcounsel-describe-function
C-h kcounsel-descbinds
C-h acounsel-apropos
C-h bcounsel-bookmark
C-c i iivy-imenu-anywhere
C-c i rivy-resume

Smex

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

Avy is for jumping to visible text using a char-based decision tree.

KeybindingCommand
M-s SPCavy-goto-word-or-subword-1
M-s savy-goto-char
M-s lavy-goto-line
M-s mavy-pop-mark
M-s ofx/avy-open-url

Company

Company-mode is used for auto-completion. C-h to abort completion may be helpful.

Yasnippet

Yasnippet is a template system for Emacs. Amazing and easy to extend.

Magit

Magit is used for magical Git integration.

KeybindingCommand
C-x g smagit-status
C-x g lmagit-log-buffer-file
C-x g Smagit-stage-file
C-x g Umagit-unstage-file

Projectile

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

Multiple-cursors gives you multi-cursor editing experience.

KeybindingCommand
C-c m cmc/edit-lines
C-c m emc/edit-ends-of-lines
C-c m amc/edit-beginnings-of-lines
C-c m rset-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

Anzu provides a minor mode which displays current match and total matches information in the mode-line in various search modes.

KeybindingCommand
M-%anzu-query-replace
C-M-%anzu-query-replace-regexp

Iedit

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.

KeyboardingCommand
C-;iedit-mode
C-h C-;iedit-mode-toggle-on-function
C-x r <return>iedit-rectangle-mode

Visual Regexp

Visual-regexp is a regexp/replace command for Emacs with interactive visual feedback.

KeybindingCommand
C-c v rvr/replace
C-c v qvr/query-replce
C-c v mvr/mc-mark

Expand Region

Expand-region increases the selected region by semantic units.

KeybindingCommand
C-M-]er/expand-region
C-M-[er/contract-region

Undo Tree

Undo tree treats undo history as a branching tree of changes, which can be run by C-x u.

Highlight Symbol

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

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.

Code Folding

HideShow hides and shows blocks of text.

KeybindingCommand
C-c z chs-hide-block
C-c z ohs-show-block
C-c z Chs-hide-all
C-c z Ohs-show-all
C-c z lhs-hide-level
C-c z zhs-toggle-hiding
C-c z <tab>hs-toggle-hiding

Window Numbering

Winum uses M-1 through M-0 to navigate window.

Buffer Move

Buffer-move is used for swapping buffers.

KeybindingCommand
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

Google-this is for launching google searches from within Emacs. C-x / is the prefix key.

Lorem Ipsum

Lorem Ipsum automatically generate dummy text.

KeybindingCommand
C-c l plorem-ipsum-insert-paragraphs
C-c l slorem-ipsum-insert-sentences
C-c l llorem-ipsum-insert-list

Crux

Crux bundles a few useful interactive commands to enhance your overall Emacs experience. I use the following frequently:

KeybindingCommand
C-acrux-move-beginning-of-line
C-ocrux-smart-open-line
C-S-ocrux-smart-open-line-above
C-<backspace>crux-kill-line-backwards
C-S-<backspace>crux-kill-whole-line
C-x f ocrux-open-with
C-x f rcrux-rename-file-and-buffer
C-x f dcrux-delete-file-and-buffer
C-x f scrux-sudo-edit

Desktop save

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.

Got Last Change

Goto-chg goes to the last place you made a change in the file.

KeybindingCommand
M-g lgoto-last-change
M-g Lgoto-last-change-reverse

Terminal

If you want to use shell within Emacs,

KeybindingCommand
C-x t eshell-pop-eshell
C-x t sshell-pop-shell
C-x t mshell-pop-multiterm
C-x t tshell-pop-ansi-term
C-x t Tshell-pop-term

Adjust Opacity

M-C-8, M-C-9 and M-C-0 are used to adjust the opacity of Emacs graphics window program.

References & Resources

About

Emacs configuration supporting C/C++, Python, LaTeX, Matlab, etc

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published