Lecture 1: The Vim Philosophy Part I Recurring Themes
• A bit more stuff... • File Explorers: locating a file • Vim Philosophy Rule I • Available commands
• A bit more stuff... • File Explorers: locating a file • Vim Philosophy Rule I • Available commands
From Last Time • Setup Vim (don't worry if you haven't done it yet, we won't be actually using Vim until much much later) • Remapped Caps Lock key, discussed ergonomics
From Last Time
From Last Time
More on Ergonomics • There's another reason why we need good ergonomics:
More on Ergonomics • There's another reason why we need good ergonomics: • Fact: Ergonomics determines speed, not the number of keystrokes...
Myth #1 • People use Vim because it can accomplish tasks with the least amount of keystrokes.
Myth #1 • People use Vim because it can accomplish tasks with the least amount of keystrokes.
Myth #1 • People use Vim because it can accomplish tasks with the least amount of keystrokes.
Myth #1 • People use Vim because it can accomplish tasks with the least amount of keystrokes. • This is also a misunderstanding... We'll get to that today.
Conventions • We have three emphasis on commands for this course: 1. Clarity 2. Ergonomics 3. Keystrokes
Conventions • We have three "emphasis" on commands for this course: 1. Clarity 2. Ergonomics 3. Keystrokes (we don't care that much) Keystrokes are good indicators of ergonomics! (kinda)
Commands Tapping the 'g' key on keyboard twice consecutively: Write As: gg Pronounced As: "gee-gee" Keycount: 2
Commands Tapping Enter: <CR> "Enter" or "Carriage Return" 1 (all these conventions would be clear when we get to vimscripting)
Commands Holding down Control and tapping d: <C-d> "Control d" 2
Commands Holding down Shift and tapping g: G "Shift g" 2
Commands For nicer formatting, sometimes we will write: qa 0w ciw lol <Esc> q For nicer formatting. Note that there are no newlines unless <CR> explicitly stated!
Commands Holding down Control and tapping x then o (while holding down control) <C-x><C-o> "Control x o" or "Control x Control o" ?
Commands Holding down Control and tapping x then o (while holding down control) <C-x><C-o> "Control x o" or "Control x Control o" 3
Commands Holding down Control and tapping x then o (while holding down control) <C-x><C-o> "Control x o" or "Control x Control o" 3 Remember: in this course, keystrokes are indicators of ergonomics, not how unix parses them!
Commands Holding down Shift and tapping '4': $ "Dollar" or "Shift Dollar" 2
Commands Holding down Shift and tapping ';': : "Colon" 1 Special case, since we'll be using it quite often.
Commands Holding down Control and tapping '[': <C-[> or <Esc> "Escape" 1 Again, 1 of the 2 special cases. We will talk about "unix standards" in the second part of the course.
A few more things about commands • Treat commands as something you want to memorize as "finger memory" (through practice). • Don't use memonics! • Same reason why you don't use memonics to remember key locations on a keyboard.
A few more things about commands • For the first few weeks we won't be using commands (even though we'll very very briefly mention them), so don't worry too much about them now. • The midterm will NOT require you to memorize commands (generally). • The final will.
Side note about .vimrc • For this course, we will build our .vimrc file from scratch. • By convention, .vimrc is the settings/resource file for vim. • The .vim directory is for plugins, addons, colors, syntax files etc. We won't get to that till much later.
For today... • We will not talk about editing in the context of code! • (we will spend the entirety of next lecture on it, since it starts getting tricky) • We will talk about editing in the context of structured text...
Quick demo of the Vim Philosophy (in a few minutes) demo.txt
• A bit more stuff... • File Explorers: locating a file • Vim Philosophy Rule I • Available commands
Case Study: Locating a File • Suppose I have a file: ~/vimcourse/demo/lecture1/ puppies/chad.txt • and I want to locate it.
Case Study: Locating a File • Suppose I have a file: ~/vimcourse/demo/lecture1/ puppies/chad.txt • and I want to locate it. • So how would you do it?
Well?
File Explorers
File Explorers
File Explorers
File Explorers Suppose we are in the puppies directory...
File Explorers Suppose we are in the puppies directory...
File Explorers eh...
File Explorers eh...
File Explorers eh...
File Explorers Sort and Binary Search!
File Explorers • So what if I wanna find a file in /bin? • This would happen...
File Explorers
File Explorers
File Explorers
File Explorers
File Explorers
File Explorers
File Explorers
File Explorers
File Explorers
The Locating Process Find ~/vimcourse/demo/lecture1/puppies/chad.txt Asks file manager to give the directory list for ~ Reads the directory list Asks the file manager to sort it Finds it through binary search Click on it. ...
The Locating Process ... Filemanager: Ohh you wanna to go to the directory 'vimcourse'. Okay, I'll take you there, Goes into the directory. Rinse and repeat. Find the file.
The Locating Process ... Filemanager: Ohh you wanna to go to the directory 'vimcourse'. Okay, I'll take you there, Goes into the directory. Rinse and repeat. Find the file. Wait a sec...
The Locating Process ... Filemanager: Ohh you wanna to go to the directory 'vimcourse'. Okay, I'll take you there, Goes into the directory. Rinse and repeat. Find the file. Wait a sec...
The Locating Process ... Filemanager: Ohh you wanna to go to the directory 'vimcourse'. Okay, I'll take you there, Goes into the directory. Rinse and repeat. Find the file. I know that file is in: ~/vimcourse/demo/...
The Locating Process ... Filemanager: Ohh you wanna to go to the directory 'vimcourse'. Why am I searching for it Okay, I'll take you there, Goes into the directory. again? Rinse and repeat. Find the file.
The Locating Process • I know the file is in: ~/vimcourse/demo/lecture1/puppies/chad .txt
The Locating Process • I know the file is in: ~/vimcourse/demo/lecture1/puppies/chad .txt • I know a command for jumping straight into the directory: cd
The Locating Process • I know the file is in: ~/vimcourse/demo/lecture1/puppies/chad .txt • I know a command for jumping straight into the directory: cd • It makes NO sense to SEARCH for it again!
The Locating Process • To put it another way: • I know the file is in that directory, • But I don't care HOW I get into that directory! • I am not responsible for finding the file, the computer is (and handling even lower level stuff).
The Locating Process https://xkcd.com/378/
Moral of the Story • Locating Files is not a FPS game. • You don't find, target and shoot. • You go straight into it. • Doing it >>>> Searching it, Finding it.
Moral of the Story • Locating Files is not a FPS game. • You don't find, target and shoot. • You go straight into it. • Doing it >>>> Searching it, Finding it. • Why do we care?
Moral of the Story • Locating Files is not a FPS game. • You don't find, target and shoot. • You go straight into it. • Doing it >>>> Searching it, Finding it. • Why do we care? Foreshadowing 10 lectures later...
In a Text Editor
In a Text Editor
In a Text Editor
Two Steps • Step 1: Locate. • Step 2: Edit.
Three Steps • Step 1: Locate. • Step 2: Edit. • Step 3: ???
Three Steps • Step 1: Locate. • Step 2: Edit. • Step 3: ??? (PROFIT!!) not really...
In a Text Editor So I've seen it...
In a Text Editor So I've seen it... goto or cd command?
In Vim
In Vim • Yup, there is such a command! • THE most frequent command you'll use for the course. /<pattern><CR>
In Vim • Yup, there is such a command! • THE most frequent command you'll use for the course. /<pattern><CR> • (but not quite actually... there are many complications, we'll talk about them next lecture...)
• A bit more stuff... • File Explorers: locating a file • Vim Philosophy Rule I • Available commands
The Vim Philosophy • To sum it up: DESCRIBE, don't EXPLAIN
Recommend
More recommend