Missing Semester 03 - Editors (Vim)
Vim's interface is a programming language 🤯.
Vim Modes
- Normal: for moving around a file and making edits (
Esc) - Insert: for inserting text (
i) - Replace: for replacing text (
R) - Visual (plain 
v, lineV, or blockctrl+v): for selecting blocks of text - Command-line: for running a command (
:) 
Some Vim Vocabulary
- a buffer: a set of open files (A given buffer may be open in multiple windows, even within the same tab)
 - a session: A Vim session has a number of tabs, each of which has a number of windows (split panes)
 - a tab: each tab has a number of windows
 - a window: a view (each window shows a single buffer)
 
Command Mode
:qclose the current window:qaclose all windows (quit Vim):q!close and discard any changes you've made (force-quit):wsave:wqsave and quit:help [topic]open help (:help :wopens help for the :w command):e[name of file] open file for editing:lsshow open buffers
Movement (normal mode)
- Basic movement: 
hjkl(left, down, up, right) - Words: 
w(next word),b(beginning of word),e(end of word) - Lines: 
0(beginning of line),^(first non-blank character),$(end of line) - Screen: 
H(top of screen),M(middle of screen),L(bottom of screen) - Scroll: 
Ctrl+u(up),Ctrl+d(down) - File: 
gg(beginning of file),G(end of file) - Find: 
f[character],t[character],F[character],T[character](Find and To)- find/to forward/backward [character] on the current line
 - , / ; for navigating matches
 
 %(find the corresponding item - brackets, quotation marks etc)- search: 
/[regex],n/Nfor navigating matches 
Editing (insert mode)
o/Oinsert line below / aboved[motion]delete [motion]- e.g. 
dwis delete word,d$is delete to end of line,d0is delete to beginning of line dddeletes the whole line
- e.g. 
 - `c[motion] change [motion] (similar to delete, but puts you in insert mode)
- e.g. 
cwis change word 
 - e.g. 
 xdelete character (equal dodl)r[character] replaces the current character with the one you typeduto undo,ctrl+rto redoyto copy / “yank”pto paste~flips the case of a character (or selection)
Selection (visual mode)
- do motion action and select everything in between
 - in Visual Line mode (
V) you'll be selecting by lines at the time - in Visual Block mode (
ctrl+v) you'll be selecting by rectangular blocks 
Counts
To perform a given action a number of times.
3wmove 3 words forward5jmove 5 lines down7dwdelete 7 words
Modifiers
Particularly useful for changing stuff inside/around brackets, quotes.
i, “inside”, anda, “around”.ci(change the contents inside the current pair of parenthesesci[change the contents inside the current pair of square bracketsda'delete a single-quoted string, including the surrounding single quotes