Skip to content
Emacs Basics — Buffers, Windows, Frames, Org-Mode, Magit, Package Management

Emacs Basics — Buffers, Windows, Frames, Org-Mode, Magit, Package Management

DodaTech Updated Jun 20, 2026 10 min read

Emacs is the extensible, customizable, self-documenting text editor that has been a cornerstone of software development for decades. This guide covers the fundamentals — buffers, windows, frames, org-mode, magit, and package management — to get you productive quickly.

What You’ll Learn

You’ll navigate and manage buffers, windows, and frames; organize notes and tasks with org-mode; use magit for Git operations; install and manage packages with MELPA; and write basic Emacs Lisp configuration. DodaZIP’s documentation and task tracking are managed entirely in org-mode files.

Why Emacs Matters

Emacs is more than an editor — it’s an operating system disguised as an editor. With org-mode for productivity, magit for Git, and thousands of packages for every conceivable task, Emacs provides a unified environment for development, writing, project management, and communication. Its extensibility means you can mold it to fit any workflow.

Learning Path

    flowchart LR
  A[Vim Basics] --> B[Emacs Basics<br/>You are here]
  B --> C[Emacs Lisp]
  C --> D[Org-mode Advanced]
  style B fill:#f90,color:#fff
  

Understanding Emacs Concepts

Terminology

TermMeaningAnalogy
BufferA document or file loaded in memoryTab in other editors
WindowA viewport into a bufferSplit pane
FrameA top-level window (in the OS sense)A new window
PointThe cursor positionThe insertion point
MarkA saved position for selectionThe start of selection
RegionText between point and markSelection
MinibufferInput area at the bottomCommand bar

Buffer Management

;; Essential buffer commands
C-x b          ;; Switch to another buffer (TAB for completion)
C-x C-b        ;; List all buffers (Buffer Menu)
C-x k          ;; Kill the current buffer
C-x C-k        ;; Kill a specific buffer
C-x s          ;; Save all unsaved buffers
C-x C-s        ;; Save the current buffer
C-x C-w        ;; Write buffer to a different filename
C-x C-f        ;; Open a file (creates a new buffer)
C-x 4 f        ;; Open file in another window

Buffer Menu Operations

# In the *Buffer List* (C-x C-b):
# d        → Mark buffer for deletion
# x        → Execute marks
# % m      → Regex mark buffers
# g        → Refresh
# s        → Save marked buffers

Windows and Frames

;; Window management
C-x 2          ;; Split window horizontally (above/below)
C-x 3          ;; Split window vertically (left/right)
C-x 0          ;; Close the current window
C-x 1          ;; Keep only the current window
C-x o         ;; Move to the other window (cycle)
C-x ^         ;; Enlarge current window vertically
C-x }         ;; Enlarge current window horizontally
C-x {         ;; Shrink current window horizontally
C-x w         ;; Balance window sizes

;; Frame management
C-x 5 2        ;; Create a new frame (new OS window)
C-x 5 0        ;; Delete the current frame
C-x 5 o        ;; Move to the next frame
C-x 5 b        ;; Switch buffer in another frame

Org-Mode

Org-mode is Emacs’s killer feature — a plain-text system for notes, TODO lists, project planning, and authoring:

;; Sample org-mode file: projects.org
#+TITLE: DodaTech Projects
#+AUTHOR: Development Team
#+DATE: 2026-06-20

* Tasks
** TODO Implement backup encryption
   SCHEDULED: <2026-06-22 Mon>
   :PROPERTIES:
   :PRIORITY: A
   :END:
   - [ ] Research encryption algorithms
   - [ ] Integrate with backup system
   - [ ] Write tests

** DONE Set up CI/CD pipeline
   CLOSED: [2026-06-19 Fri]
   - Completed with GitHub Actions

* Notes
** Deployment Architecture
   The application deploys across three tiers:
   1. Web servers (Nginx + Node.js)
   2. Application servers (Spring Boot)
   3. Database (PostgreSQL)

* Code Snippets
** Rsync Backup Command
   #+BEGIN_SRC bash
   rsync -avz --delete /source/ user@backup:/destination/
   #+END_SRC

Org-Mode Key Commands

;; Navigation
TAB            ;; Fold/unfold subtree
S-TAB          ;; Fold/unfold all
M-<up>         ;; Move heading up
M-<down>       ;; Move heading down
M-<left>       ;; Demote heading (indent)
M-<right>      ;; Promote heading (unindent)

;; TODO management
C-c C-t        ;; Cycle TODO states (TODO → DONE →)
C-c C-s        ;; Schedule date
C-c C-d        ;; Deadline date
C-c C-c        ;; Confirm/capture

;; Tags and priorities
C-c C-q        ;; Set tags
C-c ,          ;; Set priority ([#A], [#B], [#C])

;; Capture and export
C-c c          ;; Capture a quick note
C-c C-e        ;; Export (HTML, PDF, Markdown, etc.)

Magit — Git Inside Emacs

Magit is the best Git interface on any platform:

;; Start magit
C-x g          ;; Open magit status
C-x M-g        ;; Open magit dispatch menu

Magit Workflow

# In the magit status buffer (C-x g):
# s        → Stage file under cursor
# S        → Stage all files
# u        → Unstage file
# c c      → Commit (type message, C-c C-c to confirm)
# P p      → Push
# F p      → Pull from upstream
# b b      → Create branch
# b v      → Switch branch
# l l      → Log
# d d      → Diff working tree
# D d      → Diff staged (index)
# %        → Toggle hunk highlighting

# Blame
# b l      → Git blame on current file

Package Management (MELPA)

Emacs has a built-in package manager with access to thousands of packages:

;; Enable MELPA repository in init.el
(require 'package)
(add-to-list 'package-archives
    '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

;; Install packages
M-x package-install RET <package-name> RET

;; List packages
M-x package-list-packages RET

;; In the package list:
;; i        → Mark for install
;; d        → Mark for deletion
;; x        → Execute marks
;; U        → Mark all upgradable
;; g        → Refresh

Essential Packages

;; Use-package declarations for init.el
(use-package which-key                     ;; Shows available keybindings
  :ensure t
  :config (which-key-mode))

(use-package company                       ;; Auto-completion
  :ensure t
  :config (global-company-mode))

(use-package flycheck                      ;; On-the-fly syntax checking
  :ensure t
  :config (global-flycheck-mode))

(use-package projectile                    ;; Project management
  :ensure t
  :config (projectile-mode +1)
  :bind ("C-c p" . projectile-command-map))

Emacs Lisp Configuration

;; ~/.emacs.d/init.el — My personal Emacs configuration

;; Package management
(require 'package)
(add-to-list 'package-archives
    '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

;; UI customizations
(scroll-bar-mode -1)            ;; Disable scroll bars
(tool-bar-mode -1)              ;; Disable tool bar
(menu-bar-mode -1)              ;; Disable menu bar (use M-x)
(global-hl-line-mode 1)         ;; Highlight current line
(global-display-line-numbers-mode 1)  ;; Show line numbers

;; Better defaults
(setq inhibit-startup-message t)        ;; No splash screen
(setq make-backup-files nil)            ;; No ~ backup files
(setq auto-save-default nil)            ;; No auto-save
(setq column-number-mode t)             ;; Show column number

;; Indentation
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)     ;; Spaces instead of tabs

;; Keybindings
(global-set-key (kbd "C-x C-b") 'ibuffer)  ;; Better buffer list
(global-set-key (kbd "C-c C-c") 'comment-or-uncomment-region)

;; Theme
(use-package doom-themes
  :ensure t
  :config
  (load-theme 'doom-one t)
  (doom-themes-visual-bell-config))

;; Org-mode
(use-package org
  :ensure t
  :config
  (setq org-agenda-files '("~/org/"))
  (setq org-default-notes-file "~/org/notes.org"))

;; Magit
(use-package magit
  :ensure t
  :bind ("C-x g" . magit-status))

Common Emacs Mistakes

1. Using C-z Thinking It Undoes

C-z suspends Emacs (returns to shell). For undo, use C-x u or C-/ (or C-_). Suspend with C-z and return with fg in the shell.

2. Not Using C-g to Cancel

Stuck in a half-finished command? C-g quits any command, cancels minibuffer input, or exits recursive edit. It’s the universal escape button.

3. Ignoring the Minibuffer

Commands and prompts appear in the minibuffer (bottom line). If Emacs feels stuck, look at the minibuffer — it’s probably asking for input.

4. Pinky Strain from Ctrl Key

Rebind Caps Lock to Ctrl (system setting). Or use M-x instead of C-x where possible. Ergonomic keyboards or foot pedals are not unusual in the Emacs community.

5. Not Using Help

C-h ? shows all help commands. C-h k <key> describes what a key does. C-h v <variable> describes a variable. C-h f <function> describes a function. Emacs’s self-documenting nature is its greatest strength.

6. Starting with Too Many Packages

Begin with a minimal setup — add packages only when you need them. Each package adds complexity and potential conflicts. Start with org-mode, magit, and which-key.

7. Not Using Customize

M-x customize provides a GUI for changing Emacs settings. It writes the configuration to your init file automatically. Use it for settings you don’t want to learn the Lisp syntax for.

Practice Questions

1. What is the difference between a buffer and a window in Emacs? A buffer holds content (a file, a directory listing, a shell). A window is a viewport into a buffer. Multiple windows can display the same buffer. Closing a window doesn’t kill the buffer.

2. How do you navigate between open buffers? C-x b prompts for a buffer name (with TAB completion). C-x C-b lists all buffers. C-x left and C-x right cycle through recently visited buffers.

3. What does org-mode’s C-c C-t do? It cycles a heading through TODO states: TODO → DONE → (nothing). You can customize the state sequence with #+SEQ_TODO: TODO IN_PROGRESS DONE.

4. How do you stage and commit in magit? Open magit status (C-x g). Press s to stage files (or S for all). Press c then c again to start a commit. Write the message and press C-c C-c to confirm.

5. Challenge: You need to replace all occurrences of “foo” with “bar” in a 500-line file, but only within Python docstrings (not in code). How would you do this in Emacs? Answer: Use M-x query-replace-regexp with a regex that matches docstrings. Or narrow to a region with C-x n n, then M-x replace-string. Or use % s in a macro that only operates under python-mode indentation.

Mini Project: Personal Org-Mode Dashboard

Create an org-mode file that serves as your daily dashboard:

#+TITLE: Daily Dashboard
#+DATE: <2026-06-20 Sat>

* Today's Agenda
  SCHEDULED: <2026-06-20 Sat>
** TODO Review backup logs
** TODO Update server inventory
** IN_PROGRESS Write monitoring script

* Weekly Goals (Week 25)
** TODO Complete security audit
** TODO Deploy new API version

* Projects
** Web App
*** DONE User authentication module
*** TODO Payment integration
*** TODO API documentation

* References
** Useful Commands
   #+BEGIN_SRC bash
   # Check disk usage by directory
   du -sh /var/log/*
   # Watch logs in real time
   journalctl -u myapp -f
   #+END_SRC

* Journal
** 2026-06-20
   Researched backup strategies for the new deployment.
   Found that rsync with hardlink-based snapshots works best.

#+BEGIN_SRC emacs-lisp
;; Set agenda files
(setq org-agenda-files '("~/org/dashboard.org"))
;; Generate agenda view
(org-agenda nil "a")
#+END_SRC

Export this to HTML with C-c C-e h h for a rendered dashboard view.

FAQ

Is Emacs hard to learn?
Emacs has a steep initial learning curve due to its keybinding system. Start with the tutorial (C-h t), learn 10 keybindings at a time, and install which-key to see available options. Most people are comfortable within 2 weeks.
What’s the difference between Emacs and Vim?
Emacs uses modifier-key combinations (Ctrl, Meta). Vim uses modal editing (modes for insert, normal, visual). Both are extremely powerful. Emacs excels at extensibility and org-mode. Vim excels at text editing speed.
Do I need to know Emacs Lisp to use Emacs?
No — you can use Emacs for years with just package installations and the Customize interface. Learning basic Elisp lets you create your own configurations and commands.
What is org-mode used for?
Org-mode is used for TODO lists, project planning, note-taking, literate programming (org-babel), agenda management, and document authoring with export to HTML, PDF, LaTeX, Markdown, and more.
How do I get started with Emacs?
Run the built-in tutorial: C-h t. It takes about 30 minutes and covers all basics. Then install which-key (M-x package-install which-key) and enable it. Practice daily for 15 minutes.
What’s the best Emacs distribution?
Spacemacs and Doom Emacs provide pre-configured setups with Vim keybindings. Doom Emacs is currently the most popular — it’s fast, well-organized, and uses the use-package declarative configuration.

What’s Next

Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. Updated 2026-06-20.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro