lecture 1 the vim philosophy
play

Lecture 1: The Vim Philosophy Part I Recurring Themes A bit more - PowerPoint PPT Presentation

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


  1. Lecture 1: The Vim Philosophy Part I Recurring Themes

  2. • A bit more stuff... • File Explorers: locating a file • Vim Philosophy Rule I • Available commands

  3. • A bit more stuff... • File Explorers: locating a file • Vim Philosophy Rule I • Available commands

  4. 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

  5. From Last Time

  6. From Last Time

  7. More on Ergonomics • There's another reason why we need good ergonomics:

  8. More on Ergonomics • There's another reason why we need good ergonomics: • Fact: Ergonomics determines speed, not the number of keystrokes...

  9. Myth #1 • People use Vim because it can accomplish tasks with the least amount of keystrokes.

  10. Myth #1 • People use Vim because it can accomplish tasks with the least amount of keystrokes.

  11. Myth #1 • People use Vim because it can accomplish tasks with the least amount of keystrokes.

  12. 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.

  13. Conventions • We have three emphasis on commands for this course: 1. Clarity 2. Ergonomics 3. Keystrokes

  14. 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)

  15. Commands Tapping the 'g' key on keyboard twice consecutively: Write As: gg Pronounced As: "gee-gee" Keycount: 2

  16. Commands Tapping Enter: <CR> "Enter" or "Carriage Return" 1 (all these conventions would be clear when we get to vimscripting)

  17. Commands Holding down Control and tapping d: <C-d> "Control d" 2

  18. Commands Holding down Shift and tapping g: G "Shift g" 2

  19. 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!

  20. 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" ?

  21. 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

  22. 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!

  23. Commands Holding down Shift and tapping '4': $ "Dollar" or "Shift Dollar" 2

  24. Commands Holding down Shift and tapping ';': : "Colon" 1 Special case, since we'll be using it quite often.

  25. 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.

  26. 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.

  27. 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.

  28. 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.

  29. 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...

  30. Quick demo of the Vim Philosophy (in a few minutes) demo.txt

  31. • A bit more stuff... • File Explorers: locating a file • Vim Philosophy Rule I • Available commands

  32. Case Study: Locating a File • Suppose I have a file: ~/vimcourse/demo/lecture1/ puppies/chad.txt • and I want to locate it.

  33. 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?

  34. Well?

  35. File Explorers

  36. File Explorers

  37. File Explorers

  38. File Explorers Suppose we are in the puppies directory...

  39. File Explorers Suppose we are in the puppies directory...

  40. File Explorers eh...

  41. File Explorers eh...

  42. File Explorers eh...

  43. File Explorers Sort and Binary Search!

  44. File Explorers • So what if I wanna find a file in /bin? • This would happen...

  45. File Explorers

  46. File Explorers

  47. File Explorers

  48. File Explorers

  49. File Explorers

  50. File Explorers

  51. File Explorers

  52. File Explorers

  53. File Explorers

  54. 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. ...

  55. 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.

  56. 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...

  57. 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...

  58. 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/...

  59. 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.

  60. The Locating Process • I know the file is in: ~/vimcourse/demo/lecture1/puppies/chad .txt

  61. 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

  62. 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!

  63. 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).

  64. The Locating Process https://xkcd.com/378/

  65. 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.

  66. 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?

  67. 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...

  68. In a Text Editor

  69. In a Text Editor

  70. In a Text Editor

  71. Two Steps • Step 1: Locate. • Step 2: Edit.

  72. Three Steps • Step 1: Locate. • Step 2: Edit. • Step 3: ???

  73. Three Steps • Step 1: Locate. • Step 2: Edit. • Step 3: ??? (PROFIT!!) not really...

  74. In a Text Editor So I've seen it...

  75. In a Text Editor So I've seen it... goto or cd command?

  76. In Vim

  77. In Vim • Yup, there is such a command! • THE most frequent command you'll use for the course. /<pattern><CR>

  78. 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...)

  79. • A bit more stuff... • File Explorers: locating a file • Vim Philosophy Rule I • Available commands

  80. The Vim Philosophy • To sum it up: DESCRIBE, don't EXPLAIN

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend