Vim
Why use Vim
(my personal take) Vim motions are non-trivial to learn. e.g. you need to know how delete register works to effectively move around lines. Combination of usefulness as a tool (effectiveness of motion) + non-trivial but not-challenging difficulty of Vim supplies enough dopamine to keep a programmer on edge while programming (regardless of the mastery).
Vim Modes
Normal Mode (Command Mode)
- here is where you can do things like copy, paste, find, or replace, and execute commands like (:w to save,or :q to quit).
Visual Mode
- here is where you can select text.
Insert Mode
- here is where you can edit your text.
Editing
# delete d # delete selection dd # delete line, move to registry _d # delete to void "1d # delete and move val to reg position 1 "2d # delete and move val to reg position 2 "9d # max is 9 in register :reg # view delete register "1p # paste 1-st position register value "2p # paste 2-nd position register value # copy/pasting y # copy p # p pastes below the current line # undo/redo u # undo edit ctrl + r # redo edit
Behavior of p
When pasting a whole line, it pastes to line below
current.
When pasting a word(s) in current line, it pastes after
the cursor location (right side of the cursor box).
Positioning and Edit Modes
Why is right hand index finger placed on J
and not H
?
Prefer vertical movement over horizontal movement.
- prioritize use of
k
andj
to move vertically. - prioritize use of
w
,b
, ande
to jump words horizontally. - use
f{x}
when a lot of words are in a single line.
Use w
, b
, e
, and f{x}
combo to navigate current line.
For example, wrapping a word in quote should involve sequence like:
# starting from middle of the word character sequence b v e d i "" esc p
# positioning screen zz # center current view to cursor # word navigation w # move to the first character of next word e # move to the last character of current word b # move to the first character of previous word f{x} # move to first match of "x" in current line # edit mode i # insert - insert mode from beginning of currently selected word a # append - insert mode from end of currently selected word I # insert at the beginning of line A # append at the end of line