Vim with me: Gary Bernhardt

Changelog Changelog Jul 20, 2021

Audio Brief

Show transcript
This episode explores Gary Bernhart's terminal-centric Vim workflow, highlighting deep integration with Unix. There are three key takeaways from this demonstration. First, using Vim exclusively in the terminal creates a fast, seamless development environment. This approach leverages core Unix features like job control for efficient session management. Second, Vim deeply integrates with the Unix shell, enabling powerful text transformations. Text selections can be piped directly to external shell commands, with the output replacing the original selection. Third, leverage Vim's built-in keyword completion for versatile text editing. This feature operates across all open files, offering robust, language-agnostic autocomplete for any text without relying on external tools. This approach underscores a highly efficient and deeply integrated development workflow.

Episode Overview

  • This clip is a preview of a special episode of The Changelog podcast focused on the text editor Vim.
  • It features a demonstration by guest Gary Bernhart, creator of Destroy All Software and Execute Program.
  • Gary showcases his workflow, which involves running Vim exclusively within the terminal and integrating it deeply with Unix shell commands.
  • The demonstration highlights how to manage Vim instances, execute shell commands, and leverage Vim's built-in features for a powerful, terminal-centric development environment.

Key Concepts

  • Terminal-Based Vim: The practice of using Vim entirely within a command-line terminal, forgoing a graphical user interface (GUI) for speed and integration.
  • Unix Philosophy & Job Control: Leveraging core Unix features like job control (Ctrl+Z to suspend, fg to bring to foreground) to manage Vim sessions without needing multiple terminal windows or panes.
  • Shell Command Integration: Piping selected text from Vim directly to any external shell command (like sort or git blame) and having the output replace the selection, blending the editor and the shell.
  • Language-Agnostic Autocomplete: Utilizing Vim's built-in keyword completion, which works across any text file (code, prose, etc.) by tokenizing words from all open files, independent of language-specific tooling.

Quotes

  • At 00:33 - "I run Vim in the terminal all the time. I don't even have a graphical Vim installed." - Gary Bernhart explaining the foundation of his editor workflow.
  • At 01:48 - "Vim is deeply integrated with Unix in a a way that graphical editors aren't." - Highlighting the core advantage of his terminal-based approach.
  • At 02:05 - "It means that the better you get at the shell, the better you are at using Vim... and the better you get at Vim also will let you use your shell commands more." - Describing the synergistic relationship between mastering the shell and mastering Vim.

Takeaways

  • Run Vim in the terminal to create a fast and seamless workflow between your editor and shell commands.
  • Master Unix job control (Ctrl+Z, fg) to manage editing sessions within a single terminal, improving efficiency.
  • Leverage Vim's ability to filter text through shell commands (!sort, etc.) to perform powerful transformations without leaving the editor.
  • Explore Vim's built-in, buffer-based autocomplete, which is effective for any text type, not just code.