Skip to content
The Chat Archive
claude-opus-4-20250514-thinking-16k· Anthropic LMArena Human Preference 140K

what is dwim in emacs

  1. User

    what is dwim in emacs

  2. Assistant

    DWIM stands for "Do What I Mean" - it's a design philosophy in Emacs where commands try to intelligently guess what you want to do based on context.

    How DWIM works:

    • Commands examine the current context (cursor position, selected region, current mode, etc.)
    • They then perform the most likely intended action
    • This reduces the need for multiple similar commands or explicit configuration

    Common DWIM examples in Emacs:

    1. comment-dwim (M-;)

      • If there's a region selected: comment/uncomment it
      • If cursor is at end of line: add an inline comment
      • If cursor is on a line with code: jump to comment column
    2. dired-do-what-i-mean

      • In dired with two windows open: copies/moves files to the other window's directory
      • With one window: asks for destination
    3. rg-dwim (from your earlier question)

      • If point is on a symbol: searches for that symbol
      • If there's an active region: searches for the selected text
      • Otherwise: prompts for search term
      • Searches in project by default, current file with prefix arg
    4. xref-find-definitions (M-.)

      • Jumps to definition of symbol at point
      • Falls back to prompting if no symbol found

    Why DWIM?

    • Reduces cognitive load - one command handles multiple scenarios
    • Makes Emacs more intuitive for common workflows
    • Follows the principle of "smart defaults"

    The downside is that DWIM commands can sometimes be unpredictable if you're not familiar with their context-detection logic. But once you understand them, they significantly speed up your workflow.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.