Vim Productivity Techniques

Most Productive Vim Shortcuts Discussion

Essential Vim Productivity Shortcuts

Text Objects and Motion

  • ci" (Change Inside Quotes): Change text within quotes
  • da{ (Delete Around Braces): Delete including surrounding braces
  • yiw (Yank Inner Word): Copy current word
  • vip (Visual Inner Paragraph): Select entire paragraph
  • gqip (Format Inner Paragraph): Format paragraph text

Advanced Navigation

  • * and #: Search for word under cursor (forward/backward)
  • %: Jump between matching brackets/parentheses
  • gd: Go to definition of variable under cursor
  • Ctrl-o / Ctrl-i: Navigate back/forward through jump history
  • m{a-z}: Set marks, '{a-z} to jump to marks

Powerful Editing Commands

  • =: Auto-indent selected text or motion
  • gU / gu: Convert to uppercase/lowercase
  • > / <: Indent/unindent selected text
  • .: Repeat last command (extremely powerful)
  • q{a-z} / @{a-z}: Record and replay macros

Search and Replace

  • / and ?: Forward and backward search
  • n / N: Next/previous search result
  • :s/old/new/g: Substitute in current line
  • :%s/old/new/gc: Global search and replace with confirmation
  • :g/pattern/command: Execute command on lines matching pattern

Advanced Techniques

Buffer and Window Management

  • :ls: List all buffers
  • Ctrl-w commands: Window management (split, resize, navigate)
  • :b{number} or :b{name}: Switch to specific buffer
  • Ctrl-^: Switch between current and previous buffer

Command Line Efficiency

  • q:: Open command history in editable buffer
  • Ctrl-r: Insert register contents in command mode
  • !!: Repeat last shell command
  • :r !command: Insert output of shell command

Visual Mode Power

  • gv: Reselect last visual selection
  • o: Move to other end of visual selection
  • Ctrl-v: Column/block visual mode
  • I / A in visual block: Insert at beginning/end of each line

Vim Philosophy and Mindset

Composability

  • Operators + Text Objects: Commands combine (d + iw = delete inner word)
  • Counts: Numbers multiply actions (3dd = delete 3 lines)
  • Ranges: Apply commands to line ranges (10,20s/old/new/g)

Efficiency Principles

  • Minimize Keystrokes: Learn the shortest path to accomplish tasks
  • Muscle Memory: Practice common operations until they’re automatic
  • Modal Editing: Leverage different modes for different tasks
  • Text Objects: Think in terms of words, sentences, paragraphs, not characters

Learning Progression

  • Basic Navigation: Start with hjkl, basic editing
  • Text Objects: Learn word, sentence, paragraph operations
  • Advanced Motion: Search, marks, jumps
  • Customization: Adapt Vim to your specific workflow

Key Takeaways

  • Community Knowledge: Stack Overflow discussions provide real-world expertise
  • Incremental Learning: Master a few shortcuts at a time rather than trying to learn everything
  • Practice: Consistent use builds muscle memory and efficiency
  • Composability: Understanding how Vim commands combine multiplies productivity
  • Personal Optimization: Different workflows benefit from different shortcut priorities
  • Long-term Investment: Time spent learning Vim pays dividends over years of use

Vim’s power comes not from memorizing hundreds of shortcuts, but from understanding its compositional nature and developing muscle memory for the most common operations in your specific workflow.