{"captions":[{"content":"[Seminar Vim]","startTime":0,"duration":2590,"startOfParagraph":false},{"content":"[Brandon Liu] [Harvard University]","startTime":2590,"duration":1620,"startOfParagraph":false},{"content":"[This is CS50.] [CS50.TV]","startTime":4210,"duration":3290,"startOfParagraph":false},{"content":"Today is going to be an introduction to Vim.","startTime":7500,"duration":2380,"startOfParagraph":true},{"content":"How many of you guys have heard of Vim?","startTime":9880,"duration":2430,"startOfParagraph":false},{"content":"What have you heard about Vim?","startTime":12310,"duration":3310,"startOfParagraph":false},{"content":"[Student] It solves all your problems.","startTime":15620,"duration":1970,"startOfParagraph":false},{"content":"[Brandon L.] It solves all your problems.","startTime":17590,"duration":1860,"startOfParagraph":false},{"content":"Anything else you guys have heard about Vim? Any impressions?","startTime":19450,"duration":4390,"startOfParagraph":false},{"content":"[Student] Almost everyone I've talked to likes to use Vim.","startTime":23840,"duration":4150,"startOfParagraph":false},{"content":"Oh, sweet.","startTime":27990,"duration":1970,"startOfParagraph":false},{"content":"[Student] A lot of people I know like to use Vim.","startTime":29960,"duration":1130,"startOfParagraph":false},{"content":"Okay, that's good, because a lot of people in CS51","startTime":31090,"duration":3960,"startOfParagraph":false},{"content":"start to pick up Emacs because Emacs has slightly better support","startTime":35050,"duration":2950,"startOfParagraph":false},{"content":"for the language you're going to use in CS51,","startTime":38000,"duration":2100,"startOfParagraph":false},{"content":"and I worry that not enough people at Harvard use Vim,","startTime":40100,"duration":2670,"startOfParagraph":false},{"content":"so I really try and do a good job of encouraging Vim usage.","startTime":42770,"duration":3420,"startOfParagraph":false},{"content":"But here is a classic xkcd comic which you guys might find interesting.","startTime":46190,"duration":4920,"startOfParagraph":true},{"content":"Have you guys used Nano before at all?","startTime":51110,"duration":2690,"startOfParagraph":false},{"content":"This comic says Nano? Real programmers use Emacs.","startTime":53800,"duration":3580,"startOfParagraph":false},{"content":"Hey, real programmers use Vim.","startTime":57380,"duration":1660,"startOfParagraph":false},{"content":"No, real programmers use Ed which is this—you don't ever want to use Ed.","startTime":59040,"duration":4090,"startOfParagraph":false},{"content":"It's really, really old and really bad, and real programmers use ","startTime":63130,"duration":2860,"startOfParagraph":false},{"content":"a magnetized needle and a steady hand.","startTime":65990,"duration":2450,"startOfParagraph":false},{"content":"And you can read the rest, but it's pretty amusing.","startTime":68440,"duration":7570,"startOfParagraph":false},{"content":"And the funny thing is at the end. ","startTime":76010,"duration":2310,"startOfParagraph":false},{"content":"They say, \"Oh, yeah, of course, there's an Emacs command to do that.\"","startTime":78320,"duration":1990,"startOfParagraph":false},{"content":"Good old C-x M-c M-butterfly, which is sort of a jab at Emacs","startTime":80310,"duration":4740,"startOfParagraph":false},{"content":"because Emacs is historically known to be a little bit bloated","startTime":85050,"duration":3470,"startOfParagraph":false},{"content":"and to have commands for almost anything, so that's sort of a joke for Emacs.","startTime":88520,"duration":3790,"startOfParagraph":false},{"content":"What is Vim? Vim is an advanced programmer's text editor.","startTime":92310,"duration":3010,"startOfParagraph":true},{"content":"I really want to make the distinction between text editor","startTime":95320,"duration":4720,"startOfParagraph":false},{"content":"and something like a document processor.","startTime":100040,"duration":1960,"startOfParagraph":false},{"content":"Microsoft Word is known as a document processor.","startTime":102000,"duration":2340,"startOfParagraph":false},{"content":"You can set margins, make things bold, underline things,","startTime":104340,"duration":4750,"startOfParagraph":false},{"content":"strike through things, change font size and whatnot.","startTime":109090,"duration":2390,"startOfParagraph":false},{"content":"A text editor does nothing more than just edit text.","startTime":111480,"duration":2900,"startOfParagraph":false},{"content":"Literally you just have characters.","startTime":114380,"duration":1640,"startOfParagraph":false},{"content":"There's no sort of styling, sizes, fonts, colors, or anything like that.","startTime":116020,"duration":5630,"startOfParagraph":false},{"content":"All you do is edit text, and Vim has been especially made for programming.","startTime":121650,"duration":4710,"startOfParagraph":false},{"content":"It has a lot of features built in just for programming.","startTime":126360,"duration":2880,"startOfParagraph":false},{"content":"It's designed expressly for efficient text editing.","startTime":129240,"duration":2120,"startOfParagraph":false},{"content":"In general, Vim is known to be basically the fastest text editor","startTime":131360,"duration":3830,"startOfParagraph":true},{"content":"you can possibly use compared with any other text editor that's possible.","startTime":135190,"duration":3920,"startOfParagraph":false},{"content":"A lot of IDE-like features are not built directly into Vim,","startTime":139110,"duration":3370,"startOfParagraph":false},{"content":"so if you've used an IDE and you're used to things like compile and run automatically","startTime":142480,"duration":4370,"startOfParagraph":false},{"content":"or debugging what's in your IDE or a whole host of different things","startTime":146850,"duration":4030,"startOfParagraph":false},{"content":"Vim doesn't come with that naturally,","startTime":150880,"duration":1410,"startOfParagraph":false},{"content":"but there's a whole host of plugins that you can use to add that sort of functionality to Vim.","startTime":152290,"duration":4040,"startOfParagraph":false},{"content":"Vim by itself focuses on text editing and does text editing really, really well.","startTime":156330,"duration":4560,"startOfParagraph":false},{"content":"And finally, it's really customizable and extensible,","startTime":160890,"duration":2450,"startOfParagraph":false},{"content":"and basically Vim has been around, or Vi, which Vim is built upon,","startTime":163340,"duration":5400,"startOfParagraph":false},{"content":"has been around for over 40 years, and it is a very, very deep program,","startTime":168740,"duration":5050,"startOfParagraph":false},{"content":"and people will use it for a lifetime and never truly master the program to its fullest,","startTime":173790,"duration":5060,"startOfParagraph":false},{"content":"and you will always continue learning throughout your life over the years,","startTime":178850,"duration":2680,"startOfParagraph":false},{"content":"always becoming better and better.","startTime":181530,"duration":1860,"startOfParagraph":false},{"content":"There's basically no end to what you can learn and how much you can improve with Vim,","startTime":183390,"duration":4090,"startOfParagraph":true},{"content":"which is really exciting.","startTime":187480,"duration":1820,"startOfParagraph":false},{"content":"You don't want to view it as something scary because you can become very, very proficient","startTime":189300,"duration":3430,"startOfParagraph":false},{"content":"in Vim in just a few weeks but it's sort of like a continual—","startTime":192730,"duration":3920,"startOfParagraph":false},{"content":"you can always learn more and learn more and do things better and better,","startTime":196650,"duration":2220,"startOfParagraph":false},{"content":"which is kind of exciting for me.","startTime":198870,"duration":2010,"startOfParagraph":false},{"content":"This is an example of what Vim looks like.","startTime":200880,"duration":2930,"startOfParagraph":false},{"content":"This is not mine. You'll see some live demonstrations right now.","startTime":203810,"duration":3820,"startOfParagraph":false},{"content":"This is an example of what Vim might look like.","startTime":207630,"duration":1720,"startOfParagraph":false},{"content":"What we're going to do today is we're going to start off with","startTime":209350,"duration":4240,"startOfParagraph":true},{"content":" a quick showcase of what Vim can do.","startTime":213590,"duration":1670,"startOfParagraph":false},{"content":"I'm going to do some tricks and whatnot for you guys","startTime":215260,"duration":3780,"startOfParagraph":false},{"content":"so you can see why I like Vim so much and why people like Vim so much,","startTime":219040,"duration":3980,"startOfParagraph":false},{"content":"and then from there we'll go into a gentle introduction.","startTime":223020,"duration":3450,"startOfParagraph":false},{"content":"Actually, it will be a bit fast, an introduction to Vim.","startTime":226470,"duration":3060,"startOfParagraph":false},{"content":"I'll ask you guys to download a text file and to follow along with me if you can.","startTime":229530,"duration":3880,"startOfParagraph":false},{"content":"This is Vim, and right here I'm using MacVim,","startTime":233410,"duration":4670,"startOfParagraph":false},{"content":"so if you guys have Macs you may want to consider using MacVim","startTime":238080,"duration":2440,"startOfParagraph":false},{"content":"because it's a graphical version of Vim, although the regular Vim,","startTime":240520,"duration":3690,"startOfParagraph":false},{"content":"what's in your command line, works just fine.","startTime":244210,"duration":2000,"startOfParagraph":false},{"content":"I'm going to show you a few random tips and tricks","startTime":246210,"duration":3680,"startOfParagraph":false},{"content":"that you can use in Vim to show you why it's so cool.","startTime":249890,"duration":5440,"startOfParagraph":false},{"content":"Just a few random things I'm going to go through.","startTime":255330,"duration":3610,"startOfParagraph":true},{"content":"The first thing is text objects, and there are a few commands around text objects,","startTime":258940,"duration":2760,"startOfParagraph":false},{"content":"and I'll actually teach you what text objects are in more detail later in the seminar,","startTime":261700,"duration":3310,"startOfParagraph":false},{"content":"but for example, let's say I spelled my name wrong, ","startTime":265010,"duration":5040,"startOfParagraph":false},{"content":"Barndon Liu, and I want to change it.","startTime":270050,"duration":2330,"startOfParagraph":false},{"content":"All I have to do is get my cursor somewhere in my name and type in the command","startTime":272380,"duration":3760,"startOfParagraph":false},{"content":"ciw, and it will delete my whole name, put me in insert mode,","startTime":276140,"duration":2760,"startOfParagraph":false},{"content":"and I can type in my name and fix it.","startTime":278900,"duration":2150,"startOfParagraph":false},{"content":"Similarly, if I want to change something inside quotes there's also a command for that.","startTime":281050,"duration":4500,"startOfParagraph":false},{"content":"I can delete things inside quotes.","startTime":285550,"duration":1780,"startOfParagraph":false},{"content":"No more having to double click, move your hand over to the mouse,","startTime":287330,"duration":2930,"startOfParagraph":false},{"content":"double click, and then type something back in.","startTime":290260,"duration":1970,"startOfParagraph":false},{"content":"You can do everything from the keyboard, whatever it is.","startTime":292230,"duration":9770,"startOfParagraph":false},{"content":"Or alternatively, let's say I have this image tag inside this anchor tag.","startTime":302000,"duration":4430,"startOfParagraph":false},{"content":"Have you guys covered HTML in class yet?","startTime":306430,"duration":1730,"startOfParagraph":true},{"content":"Yeah, so maybe I want to delete this tag,","startTime":308160,"duration":2410,"startOfParagraph":false},{"content":"which normally what you have to do is you have to use your mouse","startTime":310570,"duration":2510,"startOfParagraph":false},{"content":"and carefully highlight exactly what you want to delete and delete it.","startTime":313080,"duration":2960,"startOfParagraph":false},{"content":"But in Vim that's simply dit, and you can delete it out really quickly,","startTime":316040,"duration":5280,"startOfParagraph":false},{"content":"and I'll explain to you what all those commands mean and how you use them in a second.","startTime":321320,"duration":6700,"startOfParagraph":false},{"content":"Another example, I have some code here,","startTime":328020,"duration":2300,"startOfParagraph":false},{"content":"and let's say I want to indent the code, but I want to indent the code","startTime":330320,"duration":3320,"startOfParagraph":false},{"content":"just within the parentheses, and I can also indent the code using 3 commands","startTime":333640,"duration":6300,"startOfParagraph":false},{"content":"using basically >iB.","startTime":339940,"duration":5420,"startOfParagraph":false},{"content":"Another thing that's really cool about Vim is something called visual block editing.","startTime":345360,"duration":4600,"startOfParagraph":false},{"content":"I don't know if you guys have ever wanted to highlight","startTime":349960,"duration":2420,"startOfParagraph":false},{"content":"a rectangular block of text in your code sometimes","startTime":352380,"duration":3310,"startOfParagraph":false},{"content":"instead of having to do this weird sort of line thing that spans all different lines.","startTime":355690,"duration":4880,"startOfParagraph":false},{"content":"For example, in Vim you can do that.","startTime":360570,"duration":1880,"startOfParagraph":false},{"content":"I can highlight rectangles like this, which is pretty cool, ","startTime":362450,"duration":2810,"startOfParagraph":false},{"content":"but furthermore, I can edit using that functionality.","startTime":365260,"duration":2690,"startOfParagraph":false},{"content":"For example, if I want to give some sort of prefix to all of our names","startTime":367950,"duration":4100,"startOfParagraph":false},{"content":"I can highlight a block and then add something.","startTime":372050,"duration":6050,"startOfParagraph":false},{"content":"Similarly, I can also highlight this block and choose to delete it,","startTime":378100,"duration":3960,"startOfParagraph":true},{"content":"or maybe I'll highlight this block and change it to D because we're all doctors.","startTime":382060,"duration":4240,"startOfParagraph":false},{"content":"Whatever it is, you can do all those different things.","startTime":386300,"duration":3130,"startOfParagraph":false},{"content":"Finally, folding is really cool. ","startTime":389430,"duration":1840,"startOfParagraph":false},{"content":"A lot of IDEs have this where you can fold different functions out of view","startTime":391270,"duration":2570,"startOfParagraph":false},{"content":"in case you don't want to see them.","startTime":393840,"duration":1750,"startOfParagraph":false},{"content":"For example, suppose I have this bunch of text here, and I don't really want to see it.","startTime":395590,"duration":4530,"startOfParagraph":false},{"content":"I want to keep it out of view because I'm editing something else in the file.","startTime":400120,"duration":2590,"startOfParagraph":false},{"content":"I can fold it up so it's all collapsed,","startTime":402710,"duration":7870,"startOfParagraph":false},{"content":"and that way it's out of view, ","startTime":410580,"duration":1570,"startOfParagraph":false},{"content":"and I can edit other things that are on the page, and this is really great.","startTime":412150,"duration":2160,"startOfParagraph":false},{"content":"You can fold up functions and whatnot or fold up classes when you're programming ","startTime":414310,"duration":3240,"startOfParagraph":false},{"content":"just to keep them out of view when you're not editing them,","startTime":417550,"duration":1830,"startOfParagraph":false},{"content":"and later when you want to see them you can open them up.","startTime":419380,"duration":4950,"startOfParagraph":false},{"content":"And you can see it just opened everything up.","startTime":424330,"duration":4930,"startOfParagraph":false},{"content":"Tabs, buffers, and windows.","startTime":429260,"duration":1960,"startOfParagraph":false},{"content":"Vim is pretty cool in that","startTime":431220,"duration":2040,"startOfParagraph":false},{"content":"normally in a lot of text editors you can only edit one file at a time,","startTime":433260,"duration":3020,"startOfParagraph":false},{"content":"like in Nano, or maybe if you're using Notepad or Gedit.","startTime":436280,"duration":2680,"startOfParagraph":false},{"content":"I've actually never used Gedit very much, but at least in Notepad++","startTime":438960,"duration":2510,"startOfParagraph":false},{"content":"you can have tabs, but Vim has the concept of tabs, buffers and windows.","startTime":441470,"duration":5230,"startOfParagraph":false},{"content":"For example, you can open up a bunch of new tabs.","startTime":446700,"duration":2060,"startOfParagraph":false},{"content":"You can see here at the very top I have now a bunch of tabs,","startTime":448760,"duration":3030,"startOfParagraph":true},{"content":"and I can close them.","startTime":451790,"duration":2560,"startOfParagraph":false},{"content":"Furthermore, there's this concept of buffers,","startTime":454350,"duration":3200,"startOfParagraph":false},{"content":"which is the idea that once you've opened a file","startTime":457550,"duration":2560,"startOfParagraph":false},{"content":"it stays alive in the buffer, and if you want to navigate to that file really quickly","startTime":460110,"duration":3800,"startOfParagraph":false},{"content":"you can navigate to it really quickly within the buffer as well,","startTime":463910,"duration":2380,"startOfParagraph":false},{"content":"and furthermore, within one pane you can also split your window up into multiple windows.","startTime":466290,"duration":5600,"startOfParagraph":false},{"content":"For example, if I want to split this window up into multiple windows","startTime":471890,"duration":4000,"startOfParagraph":false},{"content":"you can see right here that I can have the same code twice,","startTime":475890,"duration":4190,"startOfParagraph":false},{"content":"and I can split more and more and more, and right now it doesn't look that good","startTime":480080,"duration":3720,"startOfParagraph":false},{"content":"because by default I have the default window size be kind of big","startTime":483800,"duration":3540,"startOfParagraph":false},{"content":"so all the others are squashed out,","startTime":487340,"duration":2150,"startOfParagraph":false},{"content":"but normally when I'm on my computer and not on this projector","startTime":489490,"duration":2510,"startOfParagraph":false},{"content":"I can have several panes open at the same time, which is really nice for ","startTime":492000,"duration":3920,"startOfParagraph":false},{"content":"editing multiple files at the same time.","startTime":495920,"duration":5530,"startOfParagraph":false},{"content":"You can also have things like select and replace,","startTime":501450,"duration":2350,"startOfParagraph":false},{"content":"and we'll actually cover that in the seminar,","startTime":503800,"duration":4100,"startOfParagraph":false},{"content":"so I'll skip that for now.","startTime":507900,"duration":1350,"startOfParagraph":false},{"content":"You can also interact with the command line in all sorts of different ways.","startTime":509250,"duration":2789,"startOfParagraph":false},{"content":"For example, if I have some sort of list here and I want to sort it—","startTime":512039,"duration":4341,"startOfParagraph":false},{"content":"I don't know, let's add another fruit, grape,","startTime":516380,"duration":6659,"startOfParagraph":false},{"content":"and I can highlight this using the highlight function ","startTime":523039,"duration":2411,"startOfParagraph":false},{"content":"and call sort, and it will sort it automatically for me.","startTime":525450,"duration":3530,"startOfParagraph":false},{"content":"Similarly, if you're going to be editing CSS, which I presume you probably will be doing ","startTime":528980,"duration":3170,"startOfParagraph":true},{"content":"for your final project, most people do, ","startTime":532150,"duration":2040,"startOfParagraph":false},{"content":"and maybe you want to keep your CSS organized by sorting them in alphabetical order.","startTime":534190,"duration":6010,"startOfParagraph":false},{"content":"You can also highlight them and call sort, and it will sort them for you.","startTime":540200,"duration":4210,"startOfParagraph":false},{"content":"These are some of the examples of the things that Vim can do,","startTime":544410,"duration":2970,"startOfParagraph":false},{"content":"and you'll notice that the key thing that I really want to draw your attention to","startTime":547380,"duration":3380,"startOfParagraph":false},{"content":"is that I'm doing everything from the keyboard,","startTime":550760,"duration":3980,"startOfParagraph":false},{"content":"and if you are able to see where my hands are placed","startTime":554740,"duration":3280,"startOfParagraph":false},{"content":"you'll also see that my hands never really move from the home row.","startTime":558020,"duration":3190,"startOfParagraph":false},{"content":"Normally when you're editing text you usually have to use a mouse","startTime":561210,"duration":3580,"startOfParagraph":false},{"content":"and click around and whatnot, and that sort of movement drags you down","startTime":564790,"duration":3240,"startOfParagraph":false},{"content":"and wastes time, or perhaps you're moving between the home row and the arrow keys,","startTime":568030,"duration":4250,"startOfParagraph":false},{"content":"and so you're moving back and forth like that, which is a bit cumbersome ","startTime":572280,"duration":3340,"startOfParagraph":false},{"content":"but also slows you down, and the thing is once you get really good at Vim","startTime":575620,"duration":3130,"startOfParagraph":false},{"content":"everything you want to do is done without having to move your hands","startTime":578750,"duration":3600,"startOfParagraph":false},{"content":"from the home row, which is great.","startTime":582350,"duration":8380,"startOfParagraph":false},{"content":"Hold on, I'm going to open up this application. There we go.","startTime":590730,"duration":4140,"startOfParagraph":false},{"content":"Now you can see what commands are running down the lower right window.","startTime":594870,"duration":3450,"startOfParagraph":true},{"content":"All the functions that I just showed you are things that are included by default with Vim,","startTime":598320,"duration":4870,"startOfParagraph":false},{"content":"but there's also a huge number of plugins that you can also use","startTime":603190,"duration":3630,"startOfParagraph":false},{"content":"to improve your Vim experience.","startTime":606820,"duration":1570,"startOfParagraph":false},{"content":"If you downloaded the configuration files that I included,","startTime":608390,"duration":2150,"startOfParagraph":false},{"content":"and there are instructions on how to install them in the PowerPoint","startTime":610540,"duration":2610,"startOfParagraph":false},{"content":"and also in the email I sent out, I have about 40 plugins installed","startTime":613150,"duration":4690,"startOfParagraph":false},{"content":"or maybe 30 plugins, and every single one","startTime":617840,"duration":2650,"startOfParagraph":false},{"content":"brings additional functionality to Vim that improves your Vim experience.","startTime":620490,"duration":3510,"startOfParagraph":false},{"content":"For example, one of my favorites is something called surround.vim,","startTime":624000,"duration":2960,"startOfParagraph":false},{"content":"and it basically allows you to work with surrounding ","startTime":626960,"duration":2800,"startOfParagraph":false},{"content":"or delimiting characters much more easily.","startTime":629760,"duration":2440,"startOfParagraph":false},{"content":"One example, I don't know if you guys ever code in LaTeX,","startTime":632200,"duration":3760,"startOfParagraph":true},{"content":"but LaTeX is a math typesetting language that is used to make","startTime":635960,"duration":2870,"startOfParagraph":false},{"content":"really nice looking math, and whenever you want something to look like math","startTime":638830,"duration":4120,"startOfParagraph":false},{"content":"you wrap it in dollar signs, and let's say I'm typing some equation like F=ma,","startTime":642950,"duration":4100,"startOfParagraph":false},{"content":"and I forgot to wrap it in dollar signs.","startTime":647050,"duration":2190,"startOfParagraph":false},{"content":"Then I can highlight this and wrap it in dollar signs just like that.","startTime":649240,"duration":9030,"startOfParagraph":false},{"content":"Alternatively, Vim allows you to delete things inside tags","startTime":658270,"duration":5370,"startOfParagraph":false},{"content":"and delete tags and whatnot, but Vim by nature","startTime":663640,"duration":3660,"startOfParagraph":false},{"content":"doesn't allow you to change tags, so for example, I have this div tag,","startTime":667300,"duration":3100,"startOfParagraph":false},{"content":"and I want to upgrade to HTML5 and use a new header tag.","startTime":670400,"duration":2660,"startOfParagraph":false},{"content":"I can do change surrounding tag and type in header,","startTime":673060,"duration":9230,"startOfParagraph":false},{"content":"and it will automatically change that for me.","startTime":682290,"duration":4250,"startOfParagraph":false},{"content":"Similarly, let's say we have something in parentheses,","startTime":686540,"duration":3080,"startOfParagraph":false},{"content":"and I wanted to change that from parentheses into brackets or something like that.","startTime":689620,"duration":3610,"startOfParagraph":false},{"content":"I can also change that really easily by typing in c for change,","startTime":693230,"duration":3290,"startOfParagraph":false},{"content":"s for surround, parentheses.","startTime":696520,"duration":2810,"startOfParagraph":false},{"content":"Oh, I guess I have to type it faster.","startTime":699330,"duration":2840,"startOfParagraph":false},{"content":"Parentheses and braces or brackets, and it will automatically change that for me,","startTime":702170,"duration":3210,"startOfParagraph":false},{"content":"which is really nice, otherwise normally it's really cumbersome.","startTime":705380,"duration":3190,"startOfParagraph":false},{"content":"This is really nice to switch between perhaps single quote ","startTime":708570,"duration":2740,"startOfParagraph":true},{"content":"and double quote strings or something like that.","startTime":711310,"duration":1750,"startOfParagraph":false},{"content":"That's one example use case.","startTime":713060,"duration":3190,"startOfParagraph":false},{"content":"There's a plugin called Fugitive","startTime":716250,"duration":2500,"startOfParagraph":false},{"content":"which integrates with Git.","startTime":718750,"duration":1510,"startOfParagraph":false},{"content":"I'm guessing maybe you guys have not used Git that much in CS50,","startTime":720260,"duration":2740,"startOfParagraph":false},{"content":"but you'll find yourself using Git more and more and more,","startTime":723000,"duration":2530,"startOfParagraph":false},{"content":"not only in classes throughout Harvard but also at jobs and whatnot,","startTime":725530,"duration":4000,"startOfParagraph":false},{"content":"and normally you have to switch back and forth between ","startTime":729530,"duration":3120,"startOfParagraph":false},{"content":"the command line and Vim to interact with Git,","startTime":732650,"duration":3300,"startOfParagraph":false},{"content":"but there's plugins to integrate with Git from within Vim","startTime":735950,"duration":2640,"startOfParagraph":false},{"content":"and also to give you even additional functionality on top of Git.","startTime":738590,"duration":4430,"startOfParagraph":false},{"content":"There's something called NERDTree, which you can use to explore","startTime":743020,"duration":2500,"startOfParagraph":false},{"content":"the file structures from within Vim.","startTime":745520,"duration":2340,"startOfParagraph":false},{"content":"For example, I can open up NERDTree on the right pane,","startTime":747860,"duration":3850,"startOfParagraph":true},{"content":"and you can basically see random files","startTime":751710,"duration":3390,"startOfParagraph":false},{"content":"and open—not taxes, don't look at my taxes.","startTime":755100,"duration":3620,"startOfParagraph":false},{"content":"You can look at files and whatnot and open other files and so on and so forth.","startTime":758720,"duration":4740,"startOfParagraph":false},{"content":"And I won't go into these other plugins, so we can basically dive in","startTime":763460,"duration":4150,"startOfParagraph":false},{"content":"and start working on Vim, but there are plugins that allow you to","startTime":767610,"duration":4030,"startOfParagraph":false},{"content":"comment more easily, plugins that allow you to jump in between files more easily,","startTime":771640,"duration":3780,"startOfParagraph":false},{"content":"plugins that give you syntax checking from within Vim,","startTime":775420,"duration":2400,"startOfParagraph":false},{"content":"which is really cool, and it gives you syntax checking","startTime":777820,"duration":2390,"startOfParagraph":false},{"content":"for most languages right out of the box, ","startTime":780210,"duration":3500,"startOfParagraph":false},{"content":"things like rainbow parentheses, which is actually really, really cool.","startTime":783710,"duration":3750,"startOfParagraph":false},{"content":"Let me give you an example of that right now.","startTime":787460,"duration":1650,"startOfParagraph":false},{"content":"Let's see.","startTime":789110,"duration":2040,"startOfParagraph":true},{"content":"Here's some random code that I was writing,","startTime":791150,"duration":4310,"startOfParagraph":false},{"content":"and you'll notice that the brackets and parentheses are all colored,","startTime":795460,"duration":4260,"startOfParagraph":false},{"content":"and parentheses and brackets of the same color are matching, which is nice","startTime":799720,"duration":6400,"startOfParagraph":false},{"content":"and sometimes improves the readability of your code.","startTime":806120,"duration":3260,"startOfParagraph":false},{"content":"You also have autocompletion, tabular formatting.","startTime":809380,"duration":2650,"startOfParagraph":false},{"content":"When you have something that you want to get all the comments to line up","startTime":812030,"duration":5210,"startOfParagraph":false},{"content":"or you want to make a table in your text and you want to ","startTime":817240,"duration":3580,"startOfParagraph":false},{"content":"get everything to look like a nice table, instead of having to format that manually","startTime":820820,"duration":3050,"startOfParagraph":false},{"content":"there are plugins that will format that for you and so on and so forth.","startTime":823870,"duration":2960,"startOfParagraph":false},{"content":"The list goes on and on and on.","startTime":826830,"duration":2570,"startOfParagraph":false},{"content":"I could spend hours exploring all the different Vim plugins that exist,","startTime":829400,"duration":4490,"startOfParagraph":false},{"content":"and it's incredible what's out there.","startTime":833890,"duration":5890,"startOfParagraph":false},{"content":"Any questions so far? Sweet.","startTime":839780,"duration":6100,"startOfParagraph":true},{"content":"In that case, we're going to start playing around with Vim,","startTime":845880,"duration":4300,"startOfParagraph":false},{"content":"and I want you guys to work with some Vim with me","startTime":850180,"duration":2440,"startOfParagraph":false},{"content":"so you can get a feel for it, and I can guide you in your first steps working with Vim ","startTime":852620,"duration":5030,"startOfParagraph":false},{"content":"because a lot of people get overwhelmed when they open Vim up,","startTime":857650,"duration":2940,"startOfParagraph":false},{"content":"and sometimes if you don't even know the command to exit you can't even get out of Vim,","startTime":860590,"duration":4140,"startOfParagraph":false},{"content":"but it's not that bad.","startTime":864730,"duration":1620,"startOfParagraph":false},{"content":"You just need a few minutes of guidance from someone who has used Vim before","startTime":866350,"duration":2470,"startOfParagraph":false},{"content":"or to read some tutorials online, and you'll be on your way in no time.","startTime":868820,"duration":3400,"startOfParagraph":false},{"content":"Here are some instructions to install Vim if you haven't already.","startTime":872220,"duration":2350,"startOfParagraph":false},{"content":"You can look at these slides after the presentation if you want to install more things.","startTime":874570,"duration":4560,"startOfParagraph":false},{"content":"Also, these are some instructions for installing my configuration files,","startTime":879130,"duration":3530,"startOfParagraph":true},{"content":"and you can also follow these instructions later if you haven't already.","startTime":882660,"duration":5570,"startOfParagraph":false},{"content":"If you guys could go to this link and download a text file.","startTime":888230,"duration":4160,"startOfParagraph":false},{"content":"The link will take you to this text file, which I would like you to download and open up in Vim,","startTime":892390,"duration":4250,"startOfParagraph":false},{"content":"and there are a bunch of exercises and whatnot in there that you can follow around with me","startTime":896640,"duration":4940,"startOfParagraph":false},{"content":"and start getting some practice with some of the basic operations in Vim.","startTime":901580,"duration":7580,"startOfParagraph":false},{"content":"Good.","startTime":909160,"duration":3580,"startOfParagraph":false},{"content":"While you're opening that up I'm going to give a brief intro to 2 really key principles","startTime":912740,"duration":5690,"startOfParagraph":false},{"content":"in Vim editing which are really important to understand before you dive into Vim,","startTime":918430,"duration":4650,"startOfParagraph":false},{"content":"and that's modal editing and operators and motions.","startTime":923080,"duration":2640,"startOfParagraph":false},{"content":"I'll cover modal editing first, and then we'll cover operators and motions","startTime":925720,"duration":2880,"startOfParagraph":false},{"content":"in a little bit.","startTime":928600,"duration":2380,"startOfParagraph":false},{"content":"The first key distinction between Vim and pretty much all other","startTime":930980,"duration":5930,"startOfParagraph":true},{"content":"text editors of any sort is that Vim is a modal editor,","startTime":936910,"duration":2960,"startOfParagraph":false},{"content":"and what that means is when you're using Vim ","startTime":939870,"duration":2390,"startOfParagraph":false},{"content":"you could be in one of many different modes.","startTime":942260,"duration":1860,"startOfParagraph":false},{"content":"There's normal mode, there's insert mode, there's visual mode, ","startTime":944120,"duration":2470,"startOfParagraph":false},{"content":"so on and so forth, and the thing is, your keystrokes take on different actions,","startTime":946590,"duration":4200,"startOfParagraph":false},{"content":"take on different meaning, depending on what mode you're in.","startTime":950790,"duration":3370,"startOfParagraph":false},{"content":"Just as an example, normal mode is the mode you're in when you move around,","startTime":954160,"duration":3950,"startOfParagraph":false},{"content":"and so I would use the key J to move downward,","startTime":958110,"duration":3710,"startOfParagraph":false},{"content":"but in insert mode, you use the key J to actually type out J on the screen,","startTime":961820,"duration":3610,"startOfParagraph":false},{"content":"and that's why a lot of people get confused because they're not used to","startTime":965430,"duration":2800,"startOfParagraph":false},{"content":"being in different modes all the time, and so they'll be typing things out, ","startTime":968230,"duration":3400,"startOfParagraph":false},{"content":"and you're used to having whatever you type appear on the screen,","startTime":971630,"duration":2860,"startOfParagraph":false},{"content":"but in Vim maybe your cursor is moving all over the place ","startTime":974490,"duration":3880,"startOfParagraph":false},{"content":"because you're typing weird characters, and suddenly you get","startTime":978370,"duration":2650,"startOfParagraph":false},{"content":"shifted into insert mode because you typed some key ","startTime":981020,"duration":3690,"startOfParagraph":false},{"content":"that puts you into insert mode, and then text starts flying out,","startTime":984710,"duration":2440,"startOfParagraph":false},{"content":"so people get confused because of that.","startTime":987150,"duration":2790,"startOfParagraph":false},{"content":"But you have to keep track of what mode you're in,","startTime":989940,"duration":3020,"startOfParagraph":false},{"content":"and if you look at the very bottom toolbar of Vim ","startTime":992960,"duration":2300,"startOfParagraph":false},{"content":"there should be an indicator that tells you what mode you're currently in,","startTime":995260,"duration":2150,"startOfParagraph":false},{"content":"which should be helpful.","startTime":997410,"duration":1940,"startOfParagraph":false},{"content":"But in general, the 3 main modes you should know about,","startTime":999350,"duration":3300,"startOfParagraph":true},{"content":"there are only probably 6 or 7 or 8 modes or so,","startTime":1002650,"duration":3790,"startOfParagraph":false},{"content":"but you spend most of your time in 3.","startTime":1006440,"duration":2740,"startOfParagraph":false},{"content":"The first thing is normal mode. This is where you spend most of your time.","startTime":1009180,"duration":2970,"startOfParagraph":false},{"content":"All keystrokes are logged as some sort of command,","startTime":1012150,"duration":3470,"startOfParagraph":false},{"content":"and we'll be learning a lot of those commands throughout the day today.","startTime":1015620,"duration":3250,"startOfParagraph":false},{"content":"The other mode is insert mode, which is where you actually are typing things out,","startTime":1018870,"duration":4290,"startOfParagraph":false},{"content":"and insert mode is basically the mode you're usually used to.","startTime":1023160,"duration":3250,"startOfParagraph":false},{"content":"You type something, and it just comes on the screen,","startTime":1026410,"duration":2240,"startOfParagraph":false},{"content":"and visual mode is something where you can do highlighting.","startTime":1028650,"duration":3150,"startOfParagraph":false},{"content":"You saw earlier where sometimes I would be highlighting text","startTime":1031800,"duration":2950,"startOfParagraph":false},{"content":"and manipulating it in different ways, and that's an example using visual mode.","startTime":1034750,"duration":7150,"startOfParagraph":false},{"content":"We'll start off with the absolute basics you need to survive in Vim,","startTime":1041900,"duration":5919,"startOfParagraph":true},{"content":"and it's basically these 7 commands right here.","startTime":1047819,"duration":2791,"startOfParagraph":false},{"content":"HJKL are used to navigate around the file,","startTime":1050610,"duration":3640,"startOfParagraph":false},{"content":"and they correspond to left, down, up, and right,","startTime":1054250,"duration":2890,"startOfParagraph":false},{"content":"and you're free to use the arrow keys as well,","startTime":1057140,"duration":2320,"startOfParagraph":false},{"content":"but we really encourage you to use HJKL as much as possible","startTime":1059460,"duration":3650,"startOfParagraph":false},{"content":"because the idea is that while you're editing, you can move around the document","startTime":1063110,"duration":3580,"startOfParagraph":false},{"content":"without having to shift in between the arrow keys ","startTime":1066690,"duration":2660,"startOfParagraph":false},{"content":"and where you're typing, which is really, really nice.","startTime":1069350,"duration":2860,"startOfParagraph":false},{"content":"You just want to move a few characters over.","startTime":1072210,"duration":2180,"startOfParagraph":false},{"content":"You don't have to shift your entire hand over, and it's kind of nice to have that.","startTime":1074390,"duration":3630,"startOfParagraph":false},{"content":"Some Vim experts actually map their arrow keys to other functions","startTime":1078020,"duration":3900,"startOfParagraph":false},{"content":"because they already have HJKL, and they can use their arrow keys for other functions as well.","startTime":1081920,"duration":4960,"startOfParagraph":false},{"content":"HJKL moves you around while you're in normal mode.","startTime":1086880,"duration":2200,"startOfParagraph":false},{"content":"If you want to go into insert mode and type something ","startTime":1089080,"duration":2570,"startOfParagraph":false},{"content":"you can press i for insertion mode, and that puts you in insert mode,","startTime":1091650,"duration":3720,"startOfParagraph":false},{"content":"and you can type something, and you type escape","startTime":1095370,"duration":2450,"startOfParagraph":false},{"content":"to get from insertion mode back to normal mode.","startTime":1097820,"duration":2450,"startOfParagraph":false},{"content":"Escape always sends you back to normal mode","startTime":1100270,"duration":3010,"startOfParagraph":false},{"content":"no matter what mode you're in, and if you want to leave","startTime":1103280,"duration":3460,"startOfParagraph":false},{"content":"you can type in :wq enter, ","startTime":1106740,"duration":3020,"startOfParagraph":false},{"content":"and the way you can remember this is w stands for write, ","startTime":1109760,"duration":2880,"startOfParagraph":false},{"content":"and q stands for quit, so :wq,","startTime":1112640,"duration":2320,"startOfParagraph":false},{"content":"and colon runs the command, and so :wq enter to run the command","startTime":1114960,"duration":4720,"startOfParagraph":false},{"content":"saves and exits.","startTime":1119680,"duration":2160,"startOfParagraph":false},{"content":"If you open the file up we'll go through the first exercise together. ","startTime":1121840,"duration":4860,"startOfParagraph":true},{"content":"Step 1 is surviving in Vim,","startTime":1126700,"duration":2750,"startOfParagraph":false},{"content":"and hopefully you guys all have this open.","startTime":1129450,"duration":4040,"startOfParagraph":false},{"content":"Good, and we have some simple exercises for you to get used to using these keys.","startTime":1133490,"duration":4970,"startOfParagraph":false},{"content":"HJKL really doesn't seem intuitive at first, ","startTime":1138460,"duration":4540,"startOfParagraph":false},{"content":"and this is one of the initial blocks that people have while using Vim ","startTime":1143000,"duration":5710,"startOfParagraph":false},{"content":"is using these keys to navigate around.","startTime":1148710,"duration":2110,"startOfParagraph":false},{"content":"It's not intuitive, but once you get used to it","startTime":1150820,"duration":2830,"startOfParagraph":false},{"content":"it really integrates into your mind, and many people often find themselves","startTime":1153650,"duration":5940,"startOfParagraph":false},{"content":"using J and K in Word or also in Chrome, ","startTime":1159590,"duration":3960,"startOfParagraph":false},{"content":"and actually people have created this Chrome plugin called Vimium","startTime":1163550,"duration":2980,"startOfParagraph":false},{"content":"which you can use in Chrome or Chromium to navigate through Chrome","startTime":1166530,"duration":2690,"startOfParagraph":false},{"content":"using your keyboard using Vim-like shortcuts, ","startTime":1169220,"duration":2160,"startOfParagraph":false},{"content":"so people are very enthusiastic about it, but go ahead and try and use","startTime":1171380,"duration":3670,"startOfParagraph":false},{"content":"HJKL to navigate between the numbers just so you can get familiar","startTime":1175050,"duration":6670,"startOfParagraph":false},{"content":"with how these things work.","startTime":1181720,"duration":3940,"startOfParagraph":false},{"content":"Once you finish that, you can also go and play around with this maze I created","startTime":1185660,"duration":4780,"startOfParagraph":true},{"content":"just for fun, and you can sort of follow the dotted line","startTime":1190440,"duration":3140,"startOfParagraph":false},{"content":"and try not to crash into the walls","startTime":1193580,"duration":5480,"startOfParagraph":false},{"content":"and try to make it to the end of the maze.","startTime":1199060,"duration":8800,"startOfParagraph":false},{"content":"If you use shortcuts in Gmail or any number of different applications","startTime":1207860,"duration":3980,"startOfParagraph":false},{"content":"you'll find that J and K, for example, are often used to move up and down,","startTime":1211840,"duration":3290,"startOfParagraph":false},{"content":"and that basically comes from Vim essentially, so you have J and K, ","startTime":1215130,"duration":4800,"startOfParagraph":false},{"content":"and it's really nice because you can move up and down without having to","startTime":1219930,"duration":2760,"startOfParagraph":false},{"content":"move your hand back and forth from the arrow keys.","startTime":1222690,"duration":3520,"startOfParagraph":false},{"content":"Now let's try going into insertion mode and getting out of insertion mode.","startTime":1226210,"duration":3200,"startOfParagraph":false},{"content":"You'll notice that right now my cursor is a big, black box,","startTime":1229410,"duration":4960,"startOfParagraph":false},{"content":"and when you go into insertion mode you should find that","startTime":1234370,"duration":2930,"startOfParagraph":false},{"content":"it turns into a narrow cursor like you're used to.","startTime":1237300,"duration":2370,"startOfParagraph":false},{"content":"If you're using Vim in the terminal you may not find this to be the case","startTime":1239670,"duration":4060,"startOfParagraph":false},{"content":"because the terminal doesn't support this kind of thin cursor,","startTime":1243730,"duration":3240,"startOfParagraph":false},{"content":"but if you're using MacVim or GVim on Windows","startTime":1246970,"duration":2920,"startOfParagraph":false},{"content":"then you should find that it turns into a cursor, and that's a really quick visual indicator.","startTime":1249890,"duration":4700,"startOfParagraph":false},{"content":"It's for you to tell whether you're in normal mode or insertion mode.","startTime":1254590,"duration":3680,"startOfParagraph":false},{"content":"Let's go ahead and try editing this line.","startTime":1258270,"duration":4620,"startOfParagraph":true},{"content":"Fill it in with your own information or whatever it is,","startTime":1262890,"duration":3330,"startOfParagraph":false},{"content":"and how you can do that is you can move up to the end of the blank,","startTime":1266220,"duration":5530,"startOfParagraph":false},{"content":"type i to get into insertion mode, and you can backspace ","startTime":1271750,"duration":4290,"startOfParagraph":false},{"content":"and type in your name, and when you're done typing","startTime":1276040,"duration":5060,"startOfParagraph":false},{"content":"you can press escape to get out of insertion mode,","startTime":1281100,"duration":5420,"startOfParagraph":false},{"content":"and you can move over here, type insert to delete that,","startTime":1286520,"duration":9410,"startOfParagraph":false},{"content":"type escape to get out of insertion mode, and you can type :w enter","startTime":1295930,"duration":6770,"startOfParagraph":false},{"content":"to save the file. ","startTime":1302700,"duration":2020,"startOfParagraph":false},{"content":"You can type in just :w to save the file.","startTime":1304720,"duration":2700,"startOfParagraph":false},{"content":"You can type in just :q to quit without saving,","startTime":1307420,"duration":3140,"startOfParagraph":false},{"content":"or you can type in :wq to save and quit. ","startTime":1310560,"duration":3190,"startOfParagraph":false},{"content":"Granted, we don't want to quit yet, so you can type in :w.","startTime":1313750,"duration":5100,"startOfParagraph":false},{"content":"And maybe that seemed a little inefficient at first","startTime":1318850,"duration":2930,"startOfParagraph":false},{"content":"because to move to that spot you had to type J a bunch of times,","startTime":1321780,"duration":3820,"startOfParagraph":false},{"content":"maybe L a bunch of times to get to that spot,","startTime":1325600,"duration":3070,"startOfParagraph":false},{"content":"and you have to press backspace a bunch of times, and it seemed really inefficient","startTime":1328670,"duration":2590,"startOfParagraph":false},{"content":"whereas normally you would probably move your mouse over there,","startTime":1331260,"duration":2000,"startOfParagraph":false},{"content":"double click and start typing, and of course,","startTime":1333260,"duration":2620,"startOfParagraph":false},{"content":"the thing is, when you first start with Vim and you only know these basic commands,","startTime":1335880,"duration":3310,"startOfParagraph":false},{"content":"yes, it will be a little bit slower, but soon you learn some more powerful commands, ","startTime":1339190,"duration":3620,"startOfParagraph":false},{"content":"which will allow you to move across documents much more quickly,","startTime":1342810,"duration":3570,"startOfParagraph":false},{"content":"and you won't have to have this very cumbersome use of ","startTime":1346380,"duration":3030,"startOfParagraph":false},{"content":"repeating Js and repeating Ks and Ls and so on and so forth.","startTime":1349410,"duration":4920,"startOfParagraph":false},{"content":"Any questions so far? Solid.","startTime":1354330,"duration":7010,"startOfParagraph":true},{"content":"Back to the PowerPoint.","startTime":1361340,"duration":2660,"startOfParagraph":false},{"content":"Now we're going to introduce a few more commands for advanced movement.","startTime":1364000,"duration":5140,"startOfParagraph":false},{"content":"You experienced having to type maybe L a lot or H a lot, ","startTime":1369140,"duration":3540,"startOfParagraph":false},{"content":"and here are some more commands you can use to move around more quickly.","startTime":1372680,"duration":4520,"startOfParagraph":false},{"content":"Suppose that your cursor is at the O over in the some in \"This is some text,\"","startTime":1377200,"duration":5790,"startOfParagraph":false},{"content":"and here are 5 more commands you can use to move across the line more easily.","startTime":1382990,"duration":3850,"startOfParagraph":false},{"content":"So ^ and $ move you to the beginning and end line,","startTime":1386840,"duration":2980,"startOfParagraph":false},{"content":"and at some point when you learn regular expressions or other various things","startTime":1389820,"duration":4480,"startOfParagraph":false},{"content":"you'll find that these sort of conventions are very common.","startTime":1394300,"duration":3090,"startOfParagraph":false},{"content":"The ^ generally refers to the beginning of the line.","startTime":1397390,"duration":1970,"startOfParagraph":false},{"content":"The $ usually refers to the end of the line.","startTime":1399360,"duration":1730,"startOfParagraph":false},{"content":"These are very easy to remember, and similarly, b, e, and w, ","startTime":1401090,"duration":3040,"startOfParagraph":false},{"content":"they're easy to remember as well because b corresponds to back or beginning, ","startTime":1404130,"duration":4210,"startOfParagraph":false},{"content":"e corresponds to the end, which is the end of the word,","startTime":1408340,"duration":2290,"startOfParagraph":false},{"content":"and w corresponds to the next word, so w for word.","startTime":1410630,"duration":4900,"startOfParagraph":false},{"content":"And if you keep typing e or keep typing w","startTime":1415530,"duration":2220,"startOfParagraph":false},{"content":"you notice you can jump between words, and it's much faster than just typing l.","startTime":1417750,"duration":5770,"startOfParagraph":false},{"content":"Now, the next thing is the Operator-Motion Model.","startTime":1423520,"duration":3080,"startOfParagraph":true},{"content":"This is actually one of the key reasons why Vim can be so powerful,","startTime":1426600,"duration":3710,"startOfParagraph":false},{"content":"and it's because you can essentially compose different elements","startTime":1430310,"duration":4580,"startOfParagraph":false},{"content":"into more powerful functions, so generally","startTime":1434890,"duration":3360,"startOfParagraph":false},{"content":"when you do anything in Vim you can think of it as","startTime":1438250,"duration":2750,"startOfParagraph":false},{"content":"combining an operator with a motion.","startTime":1441000,"duration":2280,"startOfParagraph":false},{"content":"So far we've just dealt with motions, like HJKL. ","startTime":1443280,"duration":4030,"startOfParagraph":false},{"content":"They move you around, and then b and w, they also move you around different ways,","startTime":1447310,"duration":3460,"startOfParagraph":false},{"content":"but we haven't gone yet to being able to delete things or change things or whatnot,","startTime":1450770,"duration":3830,"startOfParagraph":false},{"content":"and when you combine operators with motions then you're able to have","startTime":1454600,"duration":4720,"startOfParagraph":false},{"content":"much more powerful effects, so for example, ","startTime":1459320,"duration":3190,"startOfParagraph":false},{"content":"if I wanted to delete 2 words, I can use d for the deletion operator,","startTime":1462510,"duration":3850,"startOfParagraph":false},{"content":"and I can add a 2 to indicate that I want to delete 2 words,","startTime":1466360,"duration":3060,"startOfParagraph":false},{"content":"and then I include a motion.","startTime":1469420,"duration":1710,"startOfParagraph":false},{"content":"I could include w to say delete 2 words.","startTime":1471130,"duration":2360,"startOfParagraph":false},{"content":"I could use something like J to say delete downward 2 times","startTime":1473490,"duration":4250,"startOfParagraph":false},{"content":"and delete 2 lines below me.","startTime":1477740,"duration":2140,"startOfParagraph":false},{"content":"I could say d2b to delete backwards twice,","startTime":1479880,"duration":3990,"startOfParagraph":false},{"content":"and there are even more motions than the ones that I've shown here","startTime":1483870,"duration":2580,"startOfParagraph":false},{"content":"to really, really make your Vim editing much more powerful.","startTime":1486450,"duration":5670,"startOfParagraph":false},{"content":"These are some of the most popular or the most common operators","startTime":1492120,"duration":3330,"startOfParagraph":true},{"content":"and are pretty easy to remember as well.","startTime":1495450,"duration":1580,"startOfParagraph":false},{"content":"D for delete, c for change.","startTime":1497030,"duration":2010,"startOfParagraph":false},{"content":"C is basically the exact same thing as change except that","startTime":1499040,"duration":2520,"startOfParagraph":false},{"content":"when you use c you automatically get put into insert mode afterwards.","startTime":1501560,"duration":4430,"startOfParagraph":false},{"content":"Normally when you use deletion you use it from normal mode, ","startTime":1505990,"duration":2060,"startOfParagraph":false},{"content":"and after you delete something you stay in normal mode.","startTime":1508050,"duration":2900,"startOfParagraph":false},{"content":"But if you want to change something, you can use c ","startTime":1510950,"duration":2430,"startOfParagraph":false},{"content":"to delete something and then immediately go into insertion mode","startTime":1513380,"duration":2580,"startOfParagraph":false},{"content":"so you can start typing and fix something.","startTime":1515960,"duration":1780,"startOfParagraph":false},{"content":"Y is for yanking.","startTime":1517740,"duration":3420,"startOfParagraph":false},{"content":"It's basically Vim's notion of copying.","startTime":1521160,"duration":3970,"startOfParagraph":false},{"content":"For example, if I want to copy the next 2 words I can do y2w or something like that,","startTime":1525130,"duration":4090,"startOfParagraph":false},{"content":"and v is for highlighting, essentially.","startTime":1529220,"duration":2900,"startOfParagraph":false},{"content":"And also what's really cool is if you type an operator twice","startTime":1532120,"duration":3430,"startOfParagraph":false},{"content":"it will act on an entire line, so if I want to delete an entire line","startTime":1535550,"duration":3340,"startOfParagraph":false},{"content":"I can type dd to delete the entire line, ","startTime":1538890,"duration":2170,"startOfParagraph":false},{"content":"or if I want to copy the entire line I can use yy or something like that.","startTime":1541060,"duration":6310,"startOfParagraph":false},{"content":"Let's try this some more.","startTime":1547370,"duration":4230,"startOfParagraph":true},{"content":"There's an exercise here for an advanced movement operator as well","startTime":1551600,"duration":4680,"startOfParagraph":false},{"content":"and even some other things I'm not going to cover in the PowerPoint today,","startTime":1556280,"duration":2950,"startOfParagraph":false},{"content":"but you can feel free to look over them later and play around with them","startTime":1559230,"duration":3020,"startOfParagraph":false},{"content":"and get familiar with them.","startTime":1562250,"duration":3740,"startOfParagraph":false},{"content":"Operators and motions.","startTime":1565990,"duration":1640,"startOfParagraph":false},{"content":"For example, suppose there are these 2 words you just want to delete in the sentence.","startTime":1567630,"duration":6590,"startOfParagraph":false},{"content":"What you'll want to do is you'll want to make sure that your","startTime":1574220,"duration":2890,"startOfParagraph":false},{"content":"cursor is at the beginning of the first word you want to delete,","startTime":1577110,"duration":3890,"startOfParagraph":false},{"content":"and you can type in d2w, and it will delete those 2 words for you.","startTime":1581000,"duration":5230,"startOfParagraph":false},{"content":"And using this exact command, d2w, may seem a bit cumbersome","startTime":1586230,"duration":6910,"startOfParagraph":false},{"content":"and pointless, but it's supposed to express the idea ","startTime":1593140,"duration":2800,"startOfParagraph":false},{"content":"that you can compose these different things, and also just in case","startTime":1595940,"duration":3440,"startOfParagraph":false},{"content":"you do happen to be in the situation, then you can end up using dw or d2w,","startTime":1599380,"duration":3350,"startOfParagraph":false},{"content":"which I do use occasionally. ","startTime":1602730,"duration":2870,"startOfParagraph":false},{"content":"Dd and cc I use much more often because you can act on entire lines.","startTime":1605600,"duration":4430,"startOfParagraph":false},{"content":"For example, let's say I have this random list here,","startTime":1610030,"duration":1970,"startOfParagraph":true},{"content":"and maybe I want to delete the line that says Huskies because it doesn't fit, just because,","startTime":1612000,"duration":7030,"startOfParagraph":false},{"content":"and I don't want it to go into insertion mode afterwards.","startTime":1619030,"duration":2170,"startOfParagraph":false},{"content":"I want to delete it, in which case I could type dd,","startTime":1621200,"duration":2330,"startOfParagraph":false},{"content":"and that will delete the entire line.","startTime":1623530,"duration":3560,"startOfParagraph":false},{"content":"But let's say now there's this other line that I want to delete,","startTime":1627090,"duration":4590,"startOfParagraph":false},{"content":"but I also want to fix it and rewrite it, in which case I'll try something like cc,","startTime":1631680,"duration":5170,"startOfParagraph":false},{"content":"and that deletes the entire line but puts me in insertion mode, as you can see, ","startTime":1636850,"duration":2700,"startOfParagraph":false},{"content":"and I can fix it from there.","startTime":1639550,"duration":5420,"startOfParagraph":false},{"content":"And there are many, many different ways you can combine operators and motions,","startTime":1644970,"duration":3540,"startOfParagraph":false},{"content":"and as you use Vim more and more you learn more about different ways","startTime":1648510,"duration":2850,"startOfParagraph":false},{"content":"you can use these commands, and you'll become better and better. ","startTime":1651360,"duration":4940,"startOfParagraph":false},{"content":"Awesome, now here are some other assorted commands ","startTime":1656300,"duration":3880,"startOfParagraph":false},{"content":"that also are very, very commonly used and also will help you become better at Vim.","startTime":1660180,"duration":4520,"startOfParagraph":false},{"content":"For example, we talked about lowercase v for visual highlighting.","startTime":1664700,"duration":4080,"startOfParagraph":true},{"content":"We can also use uppercase V for visual line highlighting.","startTime":1668780,"duration":2750,"startOfParagraph":false},{"content":"That way you can highlight entire lines at a time much more easily.","startTime":1671530,"duration":4350,"startOfParagraph":false},{"content":"You can use o when you're in normal mode to basically insert a new line","startTime":1675880,"duration":3300,"startOfParagraph":false},{"content":"below the line you're currently on and put it into insertion mode to start typing.","startTime":1679180,"duration":4440,"startOfParagraph":false},{"content":"You can use lowercase x to delete the character that's currently under your cursor.","startTime":1683620,"duration":3650,"startOfParagraph":false},{"content":"You can also use u to undo, which is kind of nice,","startTime":1687270,"duration":2960,"startOfParagraph":false},{"content":"and you can use capital A to append to the end of the current line,","startTime":1690230,"duration":3950,"startOfParagraph":false},{"content":"so perhaps your cursor is somewhere on the line, and you want to add to the end of the line.","startTime":1694180,"duration":4130,"startOfParagraph":false},{"content":"Then you can type capital A to immediately jump to the end of the line ","startTime":1698310,"duration":2840,"startOfParagraph":false},{"content":"and go into insertion mode so you can add to the end of the line.","startTime":1701150,"duration":3990,"startOfParagraph":false},{"content":"I think I have a few more exercises for that which we can try out.","startTime":1705140,"duration":5700,"startOfParagraph":true},{"content":"Actually, no, I don't. Not for those.","startTime":1710840,"duration":2400,"startOfParagraph":false},{"content":"But we have some more exercises for the next section which we'll see.","startTime":1713240,"duration":2570,"startOfParagraph":false},{"content":"But these you can try out yourself as well.","startTime":1715810,"duration":2610,"startOfParagraph":false},{"content":"For example, if you type in regular v, you'll get regular highlighting that you're used to like this.","startTime":1718420,"duration":7190,"startOfParagraph":false},{"content":"If you type in capital V, you can get full line highlighting like that,","startTime":1725610,"duration":4190,"startOfParagraph":false},{"content":"or if I type in o it basically will open a new line for me, which is kind of nice.","startTime":1729800,"duration":6050,"startOfParagraph":false},{"content":"X I can use to delete characters on the cursor.","startTime":1735850,"duration":3000,"startOfParagraph":false},{"content":"I can press x a bunch of times and delete stuff.","startTime":1738850,"duration":1950,"startOfParagraph":false},{"content":"I can press u to undo all that.","startTime":1740800,"duration":5920,"startOfParagraph":false},{"content":"A, I can type in A to immediately go to the end of the line,","startTime":1746720,"duration":2880,"startOfParagraph":false},{"content":"and I also included a few other nice keys ","startTime":1749600,"duration":4440,"startOfParagraph":false},{"content":"that you can also look at after the presentation to learn some other commands.","startTime":1754040,"duration":5200,"startOfParagraph":false},{"content":"[Student] What's replacement about?","startTime":1759240,"duration":2010,"startOfParagraph":true},{"content":"[Brandon L.] Replacement is also really cool","startTime":1761250,"duration":1800,"startOfParagraph":false},{"content":"and basically if you go somewhere—","startTime":1763050,"duration":3190,"startOfParagraph":false},{"content":"have you ever—people don't really use it that much anymore these days,","startTime":1766240,"duration":3820,"startOfParagraph":false},{"content":"but have you guys ever seen in Microsoft Word if you type insert","startTime":1770060,"duration":4280,"startOfParagraph":false},{"content":"you suddenly go into this weird mode where every single character you type","startTime":1774340,"duration":3500,"startOfParagraph":false},{"content":"basically replaces the next character?","startTime":1777840,"duration":1730,"startOfParagraph":false},{"content":"I don't know if you guys have ever seen that. ","startTime":1779570,"duration":1450,"startOfParagraph":false},{"content":"This is similar to that. ","startTime":1781020,"duration":2230,"startOfParagraph":false},{"content":"For example, if I want to overwrite what I currently have for some reason","startTime":1783250,"duration":3900,"startOfParagraph":false},{"content":"I can type in capital R, and I'll now be in replace mode, as you can see in the bottom left.","startTime":1787150,"duration":4150,"startOfParagraph":false},{"content":"If I type stuff it overwrites things, and I can also backspace, which is kind of cool,","startTime":1791300,"duration":7080,"startOfParagraph":false},{"content":"and I can undo that.","startTime":1798380,"duration":1760,"startOfParagraph":false},{"content":"I don't use that very often, but every now and then it becomes handy.","startTime":1800140,"duration":6840,"startOfParagraph":false},{"content":"Let's talk about text objects, which is one of my favorite things about Vim, honestly.","startTime":1806980,"duration":7170,"startOfParagraph":true},{"content":"Text objects are basically this notion of defining some sort of chunk of text","startTime":1814150,"duration":5510,"startOfParagraph":false},{"content":"inside your text file, and I'll go over these keys first,","startTime":1819660,"duration":6890,"startOfParagraph":false},{"content":"and then I'll give you some demonstrations for you to more fully understand what that means.","startTime":1826550,"duration":3310,"startOfParagraph":false},{"content":"W refers to a word, like a text object as a word,","startTime":1829860,"duration":4790,"startOfParagraph":false},{"content":"so some word as you normally know it, ","startTime":1834650,"duration":1830,"startOfParagraph":false},{"content":"and if there's punctuation that's next to the word","startTime":1836480,"duration":2820,"startOfParagraph":false},{"content":"then it won't include the punctuation generally.","startTime":1839300,"duration":4190,"startOfParagraph":false},{"content":"But for example, if you want to include the punctuation for some reason","startTime":1843490,"duration":2950,"startOfParagraph":false},{"content":"or you're doing something that's not English and you want to include","startTime":1846440,"duration":2640,"startOfParagraph":false},{"content":"all the characters that are delineated by whitespace ","startTime":1849080,"duration":2100,"startOfParagraph":false},{"content":"you can also use capital W to get everything that's surrounded by whitespace.","startTime":1851180,"duration":4210,"startOfParagraph":false},{"content":"You can also use parentheses to refer to a text object","startTime":1855390,"duration":3120,"startOfParagraph":false},{"content":"that's inside a set of parentheses.","startTime":1858510,"duration":1660,"startOfParagraph":false},{"content":"You can do the same thing with square brackets, angle brackets, ","startTime":1860170,"duration":3780,"startOfParagraph":false},{"content":"braces, and quotes as well, and finally,","startTime":1863950,"duration":2500,"startOfParagraph":false},{"content":"you can also use t to refer to some tag.","startTime":1866450,"duration":4520,"startOfParagraph":false},{"content":"Let me show you how that actually plays out.","startTime":1870970,"duration":4420,"startOfParagraph":true},{"content":"For example, this is my very first example in my showcase.","startTime":1875390,"duration":5990,"startOfParagraph":false},{"content":"There's some word in this sentence which I want to change,","startTime":1881380,"duration":5570,"startOfParagraph":false},{"content":"and we talked about W being used as a motion,","startTime":1886950,"duration":3610,"startOfParagraph":false},{"content":"but you can also use it as a text object like so.","startTime":1890560,"duration":2610,"startOfParagraph":false},{"content":"For example, one way I could change Barack's name or basically modify it","startTime":1893170,"duration":7770,"startOfParagraph":false},{"content":"is I could go to the beginning of this word and type in c for change and w for word,","startTime":1900940,"duration":5790,"startOfParagraph":false},{"content":"and that will delete the entire word and put it into insertion mode.","startTime":1906730,"duration":4920,"startOfParagraph":false},{"content":"But it's very annoying for me to have to go to the beginning of the word all the time.","startTime":1911650,"duration":2590,"startOfParagraph":false},{"content":"That's really annoying. I don't want to have to do that.","startTime":1914240,"duration":2290,"startOfParagraph":false},{"content":"I can actually be anywhere inside his name","startTime":1916530,"duration":3860,"startOfParagraph":false},{"content":"and type in ciw, and the i stands for inner, ","startTime":1920390,"duration":3540,"startOfParagraph":false},{"content":"so if I type in ciw it stands for change in a word,","startTime":1923930,"duration":2660,"startOfParagraph":false},{"content":"or in other words, change the word I'm currently inside,","startTime":1926590,"duration":3560,"startOfParagraph":false},{"content":"and it will give you the exact same effect.","startTime":1930150,"duration":3130,"startOfParagraph":false},{"content":"You can fix that. ","startTime":1933280,"duration":3850,"startOfParagraph":false},{"content":"Similarly, perhaps I have some case like this ","startTime":1937130,"duration":4260,"startOfParagraph":true},{"content":"where for some reason there are some delimiters or something like that,","startTime":1941390,"duration":6530,"startOfParagraph":false},{"content":"or there's some punctuation, and I wanted to delete the whole thing.","startTime":1947920,"duration":3780,"startOfParagraph":false},{"content":"If I type in ciw it will delete what's inside these delimiters, ","startTime":1951700,"duration":4830,"startOfParagraph":false},{"content":"but I want to get the whole thing that's surrounded by whitespace, ","startTime":1956530,"duration":3300,"startOfParagraph":false},{"content":"so I can use ciW to delete the whole thing. ","startTime":1959830,"duration":2920,"startOfParagraph":false},{"content":"I'll type in five, do the same thing, and type in six. ","startTime":1962750,"duration":8250,"startOfParagraph":false},{"content":"Similarly, if I want to change something that's inside the parentheses","startTime":1971000,"duration":2670,"startOfParagraph":false},{"content":"I can type in ci) to delete everything that's inside the parentheses","startTime":1973670,"duration":4670,"startOfParagraph":false},{"content":"and then fill in whatever I want to do, like int argc, whatever you want to do,","startTime":1978340,"duration":7120,"startOfParagraph":false},{"content":"and similarly, the same thing with quotes. ","startTime":1985460,"duration":1870,"startOfParagraph":false},{"content":"I can fix text that's inside of quotes,","startTime":1987330,"duration":5800,"startOfParagraph":false},{"content":"and I can also change things that are inside of tags.","startTime":1993130,"duration":8410,"startOfParagraph":false},{"content":"Does that make sense?","startTime":2001540,"duration":2860,"startOfParagraph":false},{"content":"Another thing you can do is you don't have to use c.","startTime":2004400,"duration":2620,"startOfParagraph":true},{"content":"You can also use d if you want to delete what's inside these tags. ","startTime":2007020,"duration":3670,"startOfParagraph":false},{"content":"If I want to delete the text inside a tag I can use dit to delete that tag.","startTime":2010690,"duration":4680,"startOfParagraph":false},{"content":"I can also use vit to highlight what's inside the tag, for example.","startTime":2015370,"duration":4990,"startOfParagraph":false},{"content":"The other thing is instead of using i in the middle you can also use a,","startTime":2020360,"duration":3560,"startOfParagraph":false},{"content":"which stands for all, so remember if you use i it will refer to the text object","startTime":2023920,"duration":5570,"startOfParagraph":false},{"content":"or use a text object that's contained inside the delimiters, ","startTime":2029490,"duration":2770,"startOfParagraph":false},{"content":"but if you use a it will include that text as well as the delimiter itself.","startTime":2032260,"duration":3740,"startOfParagraph":false},{"content":"For example, if I want to highlight this text and the surrounding tag","startTime":2036000,"duration":3180,"startOfParagraph":false},{"content":"I can use vat, v for visual highlight, a for all, and then t for the tag.","startTime":2039180,"duration":6210,"startOfParagraph":false},{"content":"You can do something like that as well.","startTime":2045390,"duration":2960,"startOfParagraph":false},{"content":"Maybe I want to delete this google.com with the quotes around it as well,","startTime":2048350,"duration":7460,"startOfParagraph":false},{"content":"and I can use something like da\" to delete all of that, for example.","startTime":2055810,"duration":7050,"startOfParagraph":false},{"content":"Any questions so far?","startTime":2062860,"duration":3660,"startOfParagraph":true},{"content":"I realize that I'm dumping on you a lot of Vim commands all at once,","startTime":2066520,"duration":5750,"startOfParagraph":false},{"content":"and this is basically because I want to expose you to all the different commands","startTime":2072270,"duration":3940,"startOfParagraph":false},{"content":"and give you an introduction to what these commands do in Vim.","startTime":2076210,"duration":3270,"startOfParagraph":false},{"content":"But what's going to have to happen is when you go back ","startTime":2079480,"duration":1980,"startOfParagraph":false},{"content":"you're going to have to slowly pick up these commands one by one.","startTime":2081460,"duration":2790,"startOfParagraph":false},{"content":"You don't want to overwhelm yourself, because that's too overwhelming.","startTime":2084250,"duration":3630,"startOfParagraph":false},{"content":"If you want to pick up Vim what you have to really do is ","startTime":2087880,"duration":2580,"startOfParagraph":false},{"content":"start with the first basic set, and I've broken it up into lessons for you","startTime":2090460,"duration":3130,"startOfParagraph":false},{"content":"that make it easier for you to follow, and try and master each set of commands","startTime":2093590,"duration":4240,"startOfParagraph":false},{"content":"one by one, one at a time.","startTime":2097830,"duration":2570,"startOfParagraph":false},{"content":"It's too much to do everything at once, so what you should do when you go back is","startTime":2100400,"duration":3100,"startOfParagraph":false},{"content":"go to the first lesson, which is HJKL, insertion mode, escape into normal mode,","startTime":2103500,"duration":7450,"startOfParagraph":false},{"content":"and saving and quitting, and that's all you really need to survive in Vim,","startTime":2110950,"duration":2840,"startOfParagraph":false},{"content":"and get really, really comfortable with that. ","startTime":2113790,"duration":1430,"startOfParagraph":false},{"content":"And after a few days once you're very comfortable with that","startTime":2115220,"duration":3050,"startOfParagraph":false},{"content":"you should move on to the more advanced motion operators,","startTime":2118270,"duration":2900,"startOfParagraph":false},{"content":"the more advanced motions, and on to the operators and so on and so forth. ","startTime":2121170,"duration":4720,"startOfParagraph":false},{"content":"I know I'm going through a lot, but I want to get you exposed to a lot of different things.","startTime":2125890,"duration":6270,"startOfParagraph":true},{"content":"But in case you're up for the challenge, I can show you ","startTime":2132160,"duration":3920,"startOfParagraph":false},{"content":"how you can put this all together using the most of what we just learned today,","startTime":2136080,"duration":7610,"startOfParagraph":false},{"content":"and you can also follow along if you want, ","startTime":2143690,"duration":2590,"startOfParagraph":false},{"content":"but I created some random exercise.","startTime":2146280,"duration":2310,"startOfParagraph":false},{"content":"Suppose we have some sort of roster like this ","startTime":2148590,"duration":2550,"startOfParagraph":false},{"content":"where you have these blocks with people's names, ","startTime":2151140,"duration":2060,"startOfParagraph":false},{"content":"houses, years, and concentrations and whatnot,","startTime":2153200,"duration":2240,"startOfParagraph":false},{"content":"and you want to add a new entry for yourself.","startTime":2155440,"duration":3800,"startOfParagraph":false},{"content":"What's the best way for you to do this?","startTime":2159240,"duration":2290,"startOfParagraph":false},{"content":"Let's do it like this. ","startTime":2161530,"duration":1710,"startOfParagraph":false},{"content":"Why don't we first highlight this block.","startTime":2163240,"duration":3380,"startOfParagraph":false},{"content":"You're going to select it, and we can press y to yank it, ","startTime":2166620,"duration":2090,"startOfParagraph":false},{"content":"so now we can basically copy and paste this template first","startTime":2168710,"duration":2470,"startOfParagraph":false},{"content":"without having to rewrite the whole thing from scratch.","startTime":2171180,"duration":5320,"startOfParagraph":false},{"content":"Now I'll press j down a bunch of times to go down,","startTime":2176500,"duration":3890,"startOfParagraph":false},{"content":"and I'll press p to paste it.","startTime":2180390,"duration":2170,"startOfParagraph":false},{"content":"Maybe I'll add some extra lines for a space,","startTime":2182560,"duration":4430,"startOfParagraph":false},{"content":"and let's say now I want to change your name to someone.","startTime":2186990,"duration":4140,"startOfParagraph":false},{"content":"Then I can go here and type in c2w like before to change that name.","startTime":2191130,"duration":5090,"startOfParagraph":false},{"content":"Bob Jones, who knows. ","startTime":2196220,"duration":2640,"startOfParagraph":false},{"content":"Maybe if I want to change the house I can go into the middle here ","startTime":2198860,"duration":2610,"startOfParagraph":false},{"content":"and type in ciw and put Cabot House.","startTime":2201470,"duration":2760,"startOfParagraph":false},{"content":"Here may be an example of where you may want to consider using","startTime":2204230,"duration":3620,"startOfParagraph":true},{"content":"the replacement mode to change your graduation year if you want,","startTime":2207850,"duration":5120,"startOfParagraph":false},{"content":"or we can also use ciw as well.","startTime":2212970,"duration":1920,"startOfParagraph":false},{"content":"It doesn't matter. ","startTime":2214890,"duration":2660,"startOfParagraph":false},{"content":"Maybe you want to change your major.","startTime":2217550,"duration":9630,"startOfParagraph":false},{"content":"And that's what you do.","startTime":2227180,"duration":4130,"startOfParagraph":false},{"content":"And maybe I will give you a demonstration of what I might do","startTime":2231310,"duration":5860,"startOfParagraph":false},{"content":"if I were—if you continue to learn more advanced commands in Vim ","startTime":2237170,"duration":6650,"startOfParagraph":false},{"content":"because we're barely scratching the surface here,","startTime":2243820,"duration":1870,"startOfParagraph":false},{"content":"and I could do this sort of editing even faster than I've shown you here","startTime":2245690,"duration":3270,"startOfParagraph":false},{"content":"because I know more commands that I haven't gotten a chance to show you for today.","startTime":2248960,"duration":3900,"startOfParagraph":false},{"content":"For example, if I want to highlight this I can do it like that,","startTime":2252860,"duration":4640,"startOfParagraph":false},{"content":"move down.","startTime":2257500,"duration":2460,"startOfParagraph":false},{"content":"I've added my own mapping","startTime":2259960,"duration":3900,"startOfParagraph":false},{"content":"to basically automatically highlight stuff for me","startTime":2263860,"duration":4240,"startOfParagraph":false},{"content":"and I can—I don't know. ","startTime":2268100,"duration":14510,"startOfParagraph":false},{"content":"I mean, this is just trying to show you that you can really, really ","startTime":2282610,"duration":2650,"startOfParagraph":false},{"content":"start editing things more quickly, especially when you have all these different fields,","startTime":2285260,"duration":2920,"startOfParagraph":false},{"content":"and normally what you might be doing is sort of clicking","startTime":2288180,"duration":2440,"startOfParagraph":false},{"content":"and highlighting and then typing.","startTime":2290620,"duration":2910,"startOfParagraph":false},{"content":"You can do everything all at once, copying and pasting,","startTime":2293530,"duration":5000,"startOfParagraph":false},{"content":"moving up and down between the file, ","startTime":2298530,"duration":3110,"startOfParagraph":false},{"content":"just delimiting stuff, formatting stuff.","startTime":2301640,"duration":2420,"startOfParagraph":false},{"content":"All this can be done much, much more quickly in Vim.","startTime":2304060,"duration":5610,"startOfParagraph":false},{"content":"Just one last little thing which I think may be really nice,","startTime":2309670,"duration":2910,"startOfParagraph":true},{"content":"which is find and replace.","startTime":2312580,"duration":2240,"startOfParagraph":false},{"content":"Those of you who have used Gmail shortcuts","startTime":2314820,"duration":1640,"startOfParagraph":false},{"content":"you'll also know that if you type in / it sends you to the search box,","startTime":2316460,"duration":4590,"startOfParagraph":false},{"content":"and in a lot of different applications in general you'll find that slash","startTime":2321050,"duration":3160,"startOfParagraph":false},{"content":"or maybe control slash or something to do with slash","startTime":2324210,"duration":3090,"startOfParagraph":false},{"content":"will put you into some sort of search mode,","startTime":2327300,"duration":2570,"startOfParagraph":false},{"content":"and that also basically comes from Vim essentially","startTime":2329870,"duration":3370,"startOfParagraph":false},{"content":"because the slash operator or the slash command allows you to input","startTime":2333240,"duration":5430,"startOfParagraph":false},{"content":"some sort of string that you can use to search within the document.","startTime":2338670,"duration":3100,"startOfParagraph":false},{"content":"You can n and capital N to go to the next and the previous occurrence, ","startTime":2341770,"duration":3580,"startOfParagraph":false},{"content":"and you can also use something similar to search and replace within the document.","startTime":2345350,"duration":5350,"startOfParagraph":false},{"content":"I'll give you a demonstration on what can be done.","startTime":2350700,"duration":4360,"startOfParagraph":false},{"content":"Maybe if I want to find all instances of the string yank within this document","startTime":2355060,"duration":3140,"startOfParagraph":true},{"content":"I can type in /yank, as you can see in the bottom left corner,","startTime":2358200,"duration":5110,"startOfParagraph":false},{"content":"and when I type enter it highlights all instances.","startTime":2363310,"duration":3040,"startOfParagraph":false},{"content":"I can use basically n to jump back and forth between all those different instances,","startTime":2366350,"duration":7810,"startOfParagraph":false},{"content":"and let's suppose I want to search and replace yank with some random word","startTime":2374160,"duration":6260,"startOfParagraph":false},{"content":"that's also in the document.","startTime":2380420,"duration":1760,"startOfParagraph":false},{"content":"I can press : to start typing in some sort of command within Vim,","startTime":2382180,"duration":4890,"startOfParagraph":false},{"content":"some command that's more sophisticated than moving around ","startTime":2387070,"duration":2540,"startOfParagraph":false},{"content":"or deleting or something like that.","startTime":2389610,"duration":1760,"startOfParagraph":false},{"content":"I will type in the % sign to refer that I want to use this substitution command","startTime":2391370,"duration":5490,"startOfParagraph":false},{"content":"on the entire document.","startTime":2396860,"duration":1370,"startOfParagraph":false},{"content":"Type in s for substitution. This comes from PEARL essentially.","startTime":2398230,"duration":4150,"startOfParagraph":false},{"content":"And this next command is a pretty standard command that you'll find in PEARL","startTime":2402380,"duration":4660,"startOfParagraph":false},{"content":"instead and in other programming languages that you'll ","startTime":2407040,"duration":2750,"startOfParagraph":false},{"content":"probably start to learn as you do more computer science,","startTime":2409790,"duration":3380,"startOfParagraph":false},{"content":"and I can basically use / to type a /, type in the word I want to find and replace","startTime":2413170,"duration":6960,"startOfParagraph":false},{"content":"and then type another / and type in whatever word I want to replace that word with.","startTime":2420130,"duration":4150,"startOfParagraph":false},{"content":"Who knows, maybe nyancat.","startTime":2424280,"duration":3170,"startOfParagraph":false},{"content":"I do that, and then you'll see that everything got replaced.","startTime":2427450,"duration":2940,"startOfParagraph":false},{"content":"But you'll notice that there's this word here.","startTime":2430390,"duration":3610,"startOfParagraph":true},{"content":"For some reason some of our instances of yank are replaced but not all,","startTime":2434000,"duration":3620,"startOfParagraph":false},{"content":"and that's because the way this sort of language has been written","startTime":2437620,"duration":2630,"startOfParagraph":false},{"content":"not only in Vim but in other places is that when you run the substitution command","startTime":2440250,"duration":3300,"startOfParagraph":false},{"content":"it will only substitute the first instance of that word in each line,","startTime":2443550,"duration":2920,"startOfParagraph":false},{"content":"so if I want to actually substitute all instances of the word on every single line","startTime":2446470,"duration":6340,"startOfParagraph":false},{"content":"then I have to do the same thing but add a g flag at the very end,","startTime":2452810,"duration":4080,"startOfParagraph":false},{"content":"which stands for global, and then that will actually ","startTime":2456890,"duration":3920,"startOfParagraph":false},{"content":"substitute all instances.","startTime":2460810,"duration":5390,"startOfParagraph":false},{"content":"And once you learn the regular expressions, there's actually a CS50 seminar","startTime":2466200,"duration":3510,"startOfParagraph":false},{"content":"on regular expressions, so if you're curious about regular expressions","startTime":2469710,"duration":2410,"startOfParagraph":false},{"content":"you can also take that seminar and learn more.","startTime":2472120,"duration":4850,"startOfParagraph":false},{"content":"But for example, let's say I have a list of names like this,","startTime":2476970,"duration":2950,"startOfParagraph":true},{"content":"and I want to rearrange it, so instead of having last name, comma, first name","startTime":2479920,"duration":4000,"startOfParagraph":false},{"content":"I want to rearrange it so it says first name, space, last name.","startTime":2483920,"duration":3570,"startOfParagraph":false},{"content":"You can actually use this command right here","startTime":2487490,"duration":3260,"startOfParagraph":false},{"content":"to essentially do that for you, so as you can see here ","startTime":2490750,"duration":2850,"startOfParagraph":false},{"content":"we start with an s, which means we want to do a find and replace,","startTime":2493600,"duration":3570,"startOfParagraph":false},{"content":"and then I added a flag called \\v, which is something called this magic flag ","startTime":2497170,"duration":5800,"startOfParagraph":false},{"content":"in Vim which allows you to do regular expressions more easily.","startTime":2502970,"duration":2840,"startOfParagraph":false},{"content":"Then from there we basically match for any single line","startTime":2505810,"duration":3560,"startOfParagraph":false},{"content":"that is of the form a set of words, comma, space, and a set of words or a set of letters.","startTime":2509370,"duration":6590,"startOfParagraph":false},{"content":"\\w+ basically means one or more characters,","startTime":2515960,"duration":3280,"startOfParagraph":false},{"content":"and the parentheses are used to capture these groups","startTime":2519240,"duration":4790,"startOfParagraph":false},{"content":"so I can refer to them later.","startTime":2524030,"duration":2090,"startOfParagraph":false},{"content":"As you can see, once these capture 2 blocks of words ","startTime":2526120,"duration":3790,"startOfParagraph":false},{"content":"that are separated by a comma, space ","startTime":2529910,"duration":1780,"startOfParagraph":false},{"content":"then what we want to replace it with is I use \\2 and \\1","startTime":2531690,"duration":3820,"startOfParagraph":false},{"content":"to refer back to the words that were captured","startTime":2535510,"duration":2620,"startOfParagraph":false},{"content":"in the actual find command,","startTime":2538130,"duration":2820,"startOfParagraph":false},{"content":"and so \\2 refers to whatever is contained in the second set of parentheses,","startTime":2540950,"duration":4020,"startOfParagraph":false},{"content":"\\1 refers to whatever is contained in the first set of parentheses,","startTime":2544970,"duration":3170,"startOfParagraph":false},{"content":"and as you can see, I'm putting 2 before 1 separated by a space","startTime":2548140,"duration":3540,"startOfParagraph":false},{"content":"to try and move the first name before the last name.","startTime":2551680,"duration":4970,"startOfParagraph":false},{"content":"Does that make sense?","startTime":2556650,"duration":1730,"startOfParagraph":false},{"content":"And what I can do is I can hide these first so I only run this command on these lines,","startTime":2558380,"duration":5070,"startOfParagraph":true},{"content":"and then I'll type in this command.","startTime":2563450,"duration":10270,"startOfParagraph":false},{"content":"You can see it does exactly as divided.","startTime":2573720,"duration":3330,"startOfParagraph":false},{"content":"And again, this is barely scratching the surface,","startTime":2577050,"duration":2350,"startOfParagraph":false},{"content":"and if you go to the regular expression seminar then I'm sure you'll learn ","startTime":2579400,"duration":3620,"startOfParagraph":false},{"content":"a lot more different things you can do with regular expressions,","startTime":2583020,"duration":2050,"startOfParagraph":false},{"content":"and this basically starts to hint at what you can really do with Vim ","startTime":2585070,"duration":3840,"startOfParagraph":false},{"content":"if you really start to become a master of it.","startTime":2588910,"duration":1940,"startOfParagraph":false},{"content":"Perhaps you want to refactor something, and you want to find all instances","startTime":2590850,"duration":3670,"startOfParagraph":false},{"content":"of some function that follows some sort of naming pattern.","startTime":2594520,"duration":2460,"startOfParagraph":false},{"content":"You want to change the way that's named.","startTime":2596980,"duration":1590,"startOfParagraph":false},{"content":"You can write some sort of command like this to do that for you,","startTime":2598570,"duration":2570,"startOfParagraph":false},{"content":"and that's the sort of flexibility you can get within Vim","startTime":2601140,"duration":2710,"startOfParagraph":false},{"content":"that you're just not going to get in other text editors.","startTime":2603850,"duration":6360,"startOfParagraph":false},{"content":"That basically covers all the things I wanted to teach you today in today's seminar,","startTime":2610210,"duration":4620,"startOfParagraph":true},{"content":"but again, I really want to stress that if you want to pick up Vim ","startTime":2614830,"duration":3750,"startOfParagraph":false},{"content":"it is true that there's a slightly higher learning curve in the beginning.","startTime":2618580,"duration":3540,"startOfParagraph":false},{"content":"In the very beginning you will be slightly less productive","startTime":2622120,"duration":2110,"startOfParagraph":false},{"content":"than you probably would be otherwise, but if you stick with it ","startTime":2624230,"duration":2780,"startOfParagraph":false},{"content":"within a few days or a few weeks, depending upon how fast you learn,","startTime":2627010,"duration":2880,"startOfParagraph":false},{"content":"you'll become much, much faster, and I tried to give you a demonstration","startTime":2629890,"duration":6410,"startOfParagraph":false},{"content":"on what Vim is capable of but I didn't really get a chance to show you ","startTime":2636300,"duration":2770,"startOfParagraph":false},{"content":"what happens when I normally—for example, in class I type into my notes with Vim.","startTime":2639070,"duration":4160,"startOfParagraph":false},{"content":"That's because I can work so much faster in Vim than I can with any other program.","startTime":2643230,"duration":4690,"startOfParagraph":false},{"content":"It is literally a 2 or 3 time productivity increase in Vim compared to other programs,","startTime":2647920,"duration":6560,"startOfParagraph":false},{"content":"not only with the speed of text editing but also in the way I can move around the document","startTime":2654480,"duration":4320,"startOfParagraph":false},{"content":"and the way I can access other files on my computer","startTime":2658800,"duration":2710,"startOfParagraph":false},{"content":"and jump in between them and so on and so forth.","startTime":2661510,"duration":1600,"startOfParagraph":false},{"content":"It's just a really, really huge productivity boost.","startTime":2663110,"duration":4490,"startOfParagraph":false},{"content":"But when you're learning, you want to make sure you learn one thing at a time,","startTime":2667600,"duration":2950,"startOfParagraph":true},{"content":"and try not to overwhelm yourself with too many different commands","startTime":2670550,"duration":4420,"startOfParagraph":false},{"content":"because there are a lot of commands and a lot of different shortcuts you can learn in Vim.","startTime":2674970,"duration":4120,"startOfParagraph":false},{"content":"You want to pick up a little at a time and over the years","startTime":2679090,"duration":2690,"startOfParagraph":false},{"content":"gradually amass a larger and larger understanding of Vim.","startTime":2681780,"duration":7210,"startOfParagraph":false},{"content":"If you want to continue to learn more, these are some of the more advanced topics","startTime":2688990,"duration":2800,"startOfParagraph":false},{"content":"you can continue to learn about, and even this barely scratches the surface.","startTime":2691790,"duration":4110,"startOfParagraph":false},{"content":"Here are some popular plugins you can feel free to check out and Google them","startTime":2695900,"duration":3150,"startOfParagraph":false},{"content":"and play around with them if you want to and just see what sort of plugins are out there.","startTime":2699050,"duration":4700,"startOfParagraph":false},{"content":"And then at the end of this PowerPoint, I include a bunch of links ","startTime":2703750,"duration":2510,"startOfParagraph":false},{"content":"to various resources you can use to learn from. ","startTime":2706260,"duration":2480,"startOfParagraph":false},{"content":"Here are a bunch of different links you can use to get started with Vim.","startTime":2708740,"duration":3960,"startOfParagraph":false},{"content":"They have different tutorials and whatnot,","startTime":2712700,"duration":2450,"startOfParagraph":false},{"content":"and finally, these are some more advanced things you can use ","startTime":2715150,"duration":2620,"startOfParagraph":false},{"content":"to also check out as well,","startTime":2717770,"duration":2020,"startOfParagraph":false},{"content":"some screen casts and some more advanced techniques in Vim ","startTime":2719790,"duration":2550,"startOfParagraph":false},{"content":"and also some different pieces of source code you can look up on GitHub","startTime":2722340,"duration":4110,"startOfParagraph":false},{"content":"just to look at other people's configuration files ","startTime":2726450,"duration":2310,"startOfParagraph":false},{"content":"or to look at plugins in Vim and so on and so forth.","startTime":2728760,"duration":3950,"startOfParagraph":false},{"content":"That's all I have for you.","startTime":2732710,"duration":7670,"startOfParagraph":true},{"content":"[CS50.TV]","startTime":2740380,"duration":2620,"startOfParagraph":false}]}