Introduction

  • Differences in tools for writing English words (e.g., Google Docs) versus code (e.g., IntelliJ IDEA)
  • Importance of investing time in mastering a code editor

Learning a New Editor

  • Start with a tutorial
  • Use the editor for all text editing
  • Look up better ways to do tasks

Choosing an Editor


Editor Wars

  • Programmers have strong opinions on text editors
  • Popular editors today: Visual Studio Code, Vim, … Fleet?

Vim

  • Rich history, still actively developed
  • Vim emulation modes in many tools

Philosophy of Vim


Vim’s Design

  • Focused on reading/editing over writing
  • Modal editor: different modes for inserting text vs manipulating text
  • Programmable and avoids mouse usage

Modal Editing in Vim


Different Operating Modes

  • Normal: moving around and making edits
  • Insert: inserting text
  • Others: Replace, Visual, Command-line

Mode Switching

  • <ESC> to switch to Normal mode
  • Other keys (i, R, v, V, <C-v>, :) for different modes

Basics of Vim


Inserting Text

  • i to enter Insert mode
  • <ESC> to return to Normal mode

Buffers, Tabs, and Windows

  • Buffers for open files
  • Tabs contain windows
  • Windows show buffers

Command-line Mode

  • : in Normal mode to enter
  • Commands for file operations and quitting

Movement Commands

  • Basic: hjkl (left, down, up, right)
  • Words, lines, screen, file, line numbers, find, and search

Selection in Visual Modes

  • v for Visual
  • V for Visual Line
  • Ctrl-v for Visual Block

Editing Commands

  • d{motion}, c{motion}, x, s, u, <C-r>, y, p

Counts and Modifiers

  • Combine commands with counts (3w, 5j)
  • Modifiers like i (inner) and a (around)

Customizing Vim

  • ~/.vimrc for configuration
  • Starting point: well-documented basic config

Extending Vim with Plugins

  • Built-in package management in Vim
  • Favorite plugins: ctrlp.vim, ack.vim, nerdtree, vim-easymotion

Vim-mode in Other Programs

  • Shell integration (Bash, Zsh, Fish)
  • GNU Readline library
  • Other software with vim-like keybindings

Advanced Vim

  • Search and replace
  • Multiple windows
  • Macros

Resources for Learning Vim