Insert Mode • Commands follow a 'unix standard' or convention. (usually...) • <C-h>: remove the last character. • <C-w>: remove the last word. (will be discussed in the future) • <C-u>: remove the entire line. • <C-r>: a bit more complicated... • etc. • These commands are relative to the current cursor! (quickdemo)
Insert Mode
Modal Editing • Myth #3: In Vim, you are almost always in Normal Mode.
Modal Editing • Myth #3: In Vim, you are almost always in Normal Mode. • When you are drafting in Vim, you are almost always in Insert Mode!
Modal Editing • Myth #3: In Vim, you are almost always in Normal Mode. • When you are drafting in Vim, you are almost always in Insert Mode!
Modal Editing • When using Vim, there are different phases: • Drafting -- almost always in insert mode • Skimming • Editing
Modal Editing • When using Vim, there are different phases: • Drafting -- almost always in insert mode • Skimming • Editing
Skimming • When you just want to skim/read the content of the file, you probably don't want to make modifications...
Skimming • When you just want to skim/read the content of the file, you probably don't want to make modifications... • <C-> itself provides limited number of commands...
Skimming • When you just want to skim/read the content of the file, you probably don't want to make modifications... • <C-> itself provides limited number of commands... • Most importantly, poor ergonomics!
Normal Mode • Hence, we have normal mode! • Entire mode for 2 main purposes: – Provide good skimming/scrolling commands – Provide good editing commands Without completely awful ergonomics!
Normal Mode • Hence, we have normal mode! • Entire mode for 2 main purposes: – Provide good skimming/scrolling commands – Provide good editing commands Without completely awful ergonomics!
Normal Mode • Hence, we have normal mode! • Entire mode for 2 main purposes: – Provide good skimming/scrolling commands – Provide good editing commands Without completely awful ergonomics! so far, all commands we've talked about are in normal mode! /<pattern><CR> f c d I A ea
Normal Mode
Window and Cursor Policy • Vim's cursor and screen behaves very differently from other editors.
Window and Cursor Policy • Vim's cursor and screen behaves very differently from other editors. • Principle: • cursor follows edit • screen follows view • quickdemo (lorem.txt)
Window and Cursor Policy • What this means: • skimming -- view -- screen • editing -- edit -- cursor
Window and Cursor Policy • What this means: • skimming -- view -- screen • editing -- edit -- cursor • Implication: you use different commands in different phases!
Skimming • We use the screen commands in normal mode while skimming. • They do not modify the file! • <C-d>: Half screen down • <C-u>: Half screen up • <C-e>: One line down • <C-y>: One line up • zz: Set screen to cursor in midscreen • etc... • Many commands have <C-> modifiers... Because Vim has waaaayy too many key mappings! :(
Skimming • We use the screen commands in normal mode while skimming. • They do not modify the file! • <C-d>: Half screen down • <C-u>: Half screen up • <C-e>: One line down • <C-y>: One line up • zz: Set screen to cursor in midscreen • etc... • Many commands have <C-> modifiers... Because Vim has wayy too many key mappings! :(
Modal Editing • When using Vim, there are different phases: • Drafting -- almost always in insert mode • Skimming -- always in normal mode • Editing
Modal Editing • When using Vim, there are different phases: • Drafting -- almost always in insert mode • Skimming -- always in normal mode • Editing
Editing • Complication: – Want to be able to type every character – Want to have not completely terrible ergonomics for editing commands as well....
Editing • Complication: – Want to be able to type every character – Want to have not completely terrible ergonomics for editing commands as well....
Editing • Normal modes provides commands for locating and editing (as you've seen already)... • But after using some edit command, have to specify what to edit TO.
Editing • Normal modes provides commands for locating and editing (as you've seen already)... • But after using some editing command, have to specify what to edit TO. • Solution: Call locating and editing commands in normal mode. Then jumps into insert mode to specify what to edit to....
Editing • Example: ciw lol ???
Editing • Example: ciw change current word (while in normal mode), then jumps into insert mode. lol ???
Editing • Example: ciw change current word (while in normal mode), then jumps into insert mode. lol changes the word to 'lol' (now I am in insert mode) ???
Editing • Example: ciw change current word (while in normal mode), then jumps into insert mode. lol changes the word to 'lol' (now I am in insert mode) ???
Editing • Complication: you want to continue editing by using normal mode commands....
Editing • Complication: you want to continue editing by using normal mode commands.... • But, you are currently in insert mode...
Editing • Complication: you want to continue editing by using normal mode commands.... • But, you are currently in insert mode... • So: we need some nonprintable character to jump from insert mode to normal mode!
'Escape' command <Esc>
Editing • Has debatable ergonomics... • You may choose to remap this key in the future... • Specialized purpose : escaping from insert mode to normal mode!
Editing • Example: ciw change current word (while in normal mode), then jumps into insert mode. lol changes the word to 'lol' (now I am in insert mode) <Esc> Return to normal mode!
Modal Editing • When using Vim, there are different phases: • Drafting -- almost always in insert mode • Skimming -- always in normal mode • Editing -- always alternating between normal mode and insert mode
Modal Editing • When using Vim, there are different phases: • Drafting -- almost always in insert mode • Skimming -- always in normal mode • Editing -- always alternating between normal mode and insert mode • Takeaway: do not be afraid of insert mode! Many actions should be done in insert mode!
Recommend
More recommend