iannjh blog

Emacs 效率指南:从入门到极客

$ emacs –why

Emacs is not just an editor — it's an operating system that happens to have a good text editor. Here's my guide to going from "What is this?" to "I live in Emacs now."

Essential Keybindings

C-x C-f    find-file          — open a file
C-x C-s    save-buffer        — save
C-x C-c    save-buffers-kill  — quit (eventually)
C-g        keyboard-quit      — ESCAPE FROM EVERYTHING
M-x        execute-extended   — the command palette
C-h k      describe-key       — what does this key do?

Must-Have Packages

Org-mode (built-in, but configure it)

;; Better Org defaults
(setq org-startup-indented t
      org-hide-leading-stars t
      org-log-done 'time)

Vertico + Consult (modern completion)

Replace the default minibuffer with something sane:

(use-package vertico
  :init (vertico-mode))

(use-package consult
  :bind (("C-x b" . consult-buffer)
         ("C-c g" . consult-grep)))

Magit (git, but actually enjoyable)

(use-package magit
  :bind (("C-x g" . magit-status)))

Pro Tips

  1. Use C-h everywhere — Emacs has the best documentation of any software ever written. Press C-h k to learn what any key does.
  2. Kmacro is your friendF3 to start recording, F4 to replay. Macros beat repetitive editing every time.
  3. Multiple cursors — install multiple-cursors package and never manually edit 50 similar lines again.
  4. Dired for file managementC-x d opens a file manager. Yes, inside Emacs.

The .emacs.d Philosophy

"Your .emacs.d is your castle. Build it brick by brick, and never copy someone else's config wholesale."

Start minimal. Add only what you need. Understand every line.

;; A minimal init.el
(package-initialize)
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file 'noerror)
;; ... add your config below

Conclusion

Emacs has a steep learning curve, but the payoff is immense. You get an editor that adapts to your workflow, not the other way around.

$ emacs --version
GNU Emacs 29.x
Copyright (C) 2024 Free Software Foundation, Inc.

Next up: Terminal Aesthetics — making your shell look like a cyberpunk movie.

────────────────────────────────────────

Built with Emacs Org-mode & ❤

No JavaScript. No tracking. Just text.

Copyright © iannjh. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation.