Intermediate Vim

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
um this seminar it's kind of important that you already know a bit about him kind of important so if you have never had any experience with them you might be a little lost and we can't really help does anyone fall in that category okay cool so you're all you've all done vim tutor or you know hjkl you know that sort of stuff right right okay cool you're good people hello welcome obviously now to get started I'm Austin the president from CCM this is Robert vice president like I said we're talking about vim the best editor around not Emacs Nano or Pico it's not sublime tax free text makes BIM that's right some people say it's an extra people know it but we think they're wrong well you see the way I think about it is Emacs has an evil mode to emulate VI behavior so it's conceded victory to VIN and pleasantly no it's not because evil mode comes close but it's not there okay there were it's a decent operating system with a good texture all right so this seminar is not so much learn how to do but here's a bunch of cool stuff you can do we're going to go through a lot of material and if we want to keep it quick we're going to have to move through it kind of slow but we are going to have some quickly we're gonna have to look through kinda quickly not so Robert is actually going to do some stuff done thinning over on the projector while we talk about what we're doing so we actually a lot a lot of content to go through if you have any questions please raise your hand also feel free to follow the lawn on your own computer because it has been why not say what yeah as almost no is part way yeah five years never mind that's pretty close kind of like latex it's kind of five years old well so that further ado Robert what's coming up so we're going to start out with setting some expectations for this discussion I know Austin's already kind of hit on that a little bit and then we're going to be talking about what has been and what are all these great features that we've been talking about let me get into those great yes so let's set expectations Austin's already said that we're not going to cover what Vin tutor covers you this is designed to be an intermediate to advanced level seminar this is not going to make you a femme guru that comes with a lot of practice because some of this is neat tricks and stuff but you actually need to commit these things to muscle memory before they actually start being really useful we're only going to show you less than 10% of Bin's capabilities number give or take so this quote on the bottom of the screen you'll see it's kind of small actually is actually from the vehm guru that I learned from and it says most people use only about 10% of the functionality of them that 10% of functionality varies from person to person and that's very much true we're going to be covering some stuff today that's very useful for programming and general text editing but generally in kind of useful stuff some things this discussion will do is show you some of what we think are the coolest features of them and give you some tools to help teach yourself how to learn more so what is Vinh it's a programmers text editor that means it's going to provide features that help you program code faster and easier and help debug that code good for running yeah I use it to write letters once a month also it's an incredibly valuable tool to master I've ran across just in my job five or six things a day that I probably saved myself 10 or 15 minutes by doing a quick vem script or a quick macro it's very very powerful but that said vim is not all of your tools in your toolbox there are some things that then does not do very well and if you want to learn more about some of those other tools that you should have in your toolbox you should come back in two weeks when we cover various different UNIX and Linux tools so one of the biggest and most important things to understand about vim from the get-go is this concept of composability so every command that you do in vim is split up into two parts what we're going to call an action and what we're going to call a motion almost yeah but there's several commands that are split up in this way so actions do something like delete Allah delete or put or change these are actions that we think about but this also what are called motions motions are plays to move the cursor we're going to be talking a little bit more about motions in a second we'll demonstrate it at that point but it's important to realize that in them commands that you do are a combination of both so for example you can delete a line as well as delete a paragraph the Delete key is used in both of them and the motion for a line is used for the line version and devotion for a paragraph is used in the paragraph version so by learning just a small set of actions and a small set of commands they come together to represent a much larger scope of functionality so understanding this concept I would say is fundamental to moving forward and understanding them so and this is Austin's quote here most editors don't have anything like this it's really kind of a different concept sublime text has stimulated with vintage mode so let's talk about some of the motions that you can do now not all of these or the ones that can be combined with the thanks Rob my name is a question yes yes so what's your try airline or what harmonic was your life that will cover that in them are seen just a minute okay well I have the presentation right here so I don't have to complain a router every time you changes it's a good thing so one of the first point is yeah it's more MEPs in there for you as these okay so one of the first things that I wanted to point out is one of my favorite demands it's not actually something you can really inject and severe of deleting stuff and changing and moving around a bit it's going to the last point where you know something is G cynical people go back with G : Eugene Thomas and so the proper ads anything and then go everything is misspelled all right Robert show us in you yes if you change something and then want to go back to where that was then you can just use a Jew Senegal now that's not quite as applicable maybe as the text objects these are really super useful you can combine an object with an A or Die it's much better to actually just demonstrate it you can try to explain but as an action well as a motion you can use for example a W to say I want to do something to over I'm using v2o we don't know he yet okay just work some subtext objects are a word a sentence with s paragraph a block or a different kind of block these things are pretty useful primarily because if you're sitting in the middle of word makes hype dat double u then you can take that entire work without having to go to the end Ranma you can also change so if you want to replace a word if you do see iw the difference between a I is and group like a whole thing or the inner part of it so an example is if you want to delete an entire quote area you can type da folks that illegal thing you want to change what's inside of it you can go see I boats Roberts they're pretty useful there I think you're in help now that help motion so looking along from the text objects those things are really useful a neat movement is to the next character that's T&F what yes as posture our local expert says it very useful so if you want to go to the next instance of a character go to see your sign height:4em then you can go you can type TSM to get to that 8 or fm to get to the end itself you can combine that with a deletion or change or something so if you're at the beginning of the line and want to leave through the m DF m or e TM and then you can just easily get rid of also the pipe is removing to a specific column you have to pretend it with a number to get greater goal g j and j k weegee paid our things you might want to include them popper of The Bachelor MRC later because you can remap them to the normal JK and what those do is if you have something approaches like this then you can move the cursor between the wrapped lines normally with G and K when you're moving up and down he'll go to the next actual line so this bill thinks there are four lines here we can see there anymore with GJ and GK and just skip to what the actual wrapped line I think Robert has the right no this is the parentheses are moving car from moving between sentences so those are not blocks not objects you can see if you write stop using visual okay this is you use it if you just do a parenthesis then you'll move between sentences it's denoted by a period and maybe other period in white space space then the braces are paragraphs those are something online a paragraph is to note in violin ng line so if you this thing is an entire paragraph if you insert a line between three five three four then those would be NZ's move between paragraphs so that's very useful you can delete a paragraph or just scroll this one scroll down the whole list of stuff is pretty cool it's if you're interested in finding out more about moving around really quickly take a look at health motion duck take steam we're going to be seeing this command a lot its : H and then the name of anything just : H will take you to a page that explains how the help works and how to get more stuff we took a lot of this documentation from the health documents there's a lot of those so it's hard just know Roberts going to talk a little bit about okay so now that we know 50 bajillion different ways to get to any particular spot in text it's important that we try to do so efficiently have you ever found yourself while you're typing something in them hitting like lllll oh yes Robert keeping going to the end of a line you're trying to get to a specific location so if you find yourself doing that a lot chances are what you're doing is an anti-pattern there's another command in vim that will help you do whatever you're trying to do better and faster so for example if you're typing DDO to change the current line to something else you can stead instead just use s so DDO or just shift s it does the same thing next you could do dbx so delete to the beginning of the word and then delete the current character versus da w now this is a slightly subtler variety of anti-pattern because strictly speaking yes they do exactly the same thing and they do it in exactly the strength same number of key presses the catch here though is the second action is what's called repeatable whereas the first one is not so let's talk about enemies yeah similarly similarly you could use find open brace LVT close curly brace shift you in order to do the same thing will again do rather that would select everything inside of a tag like an HTML tag so we'll demonstrate here real quick for some reason we forgot when you use what visual mode is it gets only useful it's a bunch of variations on in B and basically get what you said you're seeing right here you can select text using movements and stuff and then do a bunch of cool things to that entire selected text so that kind gives you an idea of what a tag is that said though you shouldn't be thinking for three minutes every time you want to type something is there a more efficient way to do this and you could it'd be fun but you're not going to get very much done that way so the big takeaway from this is when you find yourself doing something and a lot and you're thinking oh gosh there has to be a better way to do this chances are you're right and then it's time to find it so let's talk about fixing some common annoyances in them there is a file in your home directory called dot MRC it contains common settings that you may have in your program or in your per film so for example about that hugging stuff yeah so here's an example example of some stuff out of my MRC so I turn the mouse on hitting escape is kind of a pain because it's all the way up on your left pinky roughly yeah I'm lazy so I just remapped double tapping J in insert mode to escape it makes it a lot easier to not have to hit escape as often a lot of other people will also remap the control or the caps lock button on their keyboards to the neck strap control key which makes it easier to do one of the other escape commands in them so definitely a very useful thing to have so three months yeah his is like what 300 yeah should be longer yeah so another thing that you may want to do is by default them does not turn on syntax highlighting so it's very easy to fix that you just in your VMRC add a line that says syntax on and then it'll start highlighting all your text and you'll be thinking where has this been all my life another thing you probably want to do is if you're like me and you use a dark background two-terminal you probably want to set background equal to dark that will change the color scheme just slightly so it's a little easier on the eyes on a black terminal in case you're wondering there is also a set background equal light but it's also the default so you don't need to set it so any questions about them are see there are Brazilians of people's NRCS and bachelors days and bunch of other RCS on github directories in every posts and websites all sorts of stuff so it's very easy to find some great examples rusty had asked how I had this like the power line symbols on the text it's actually a plug-in called air line we'll talk about that yeah okay so the other thing that you're probably wondering when you first get into them is where did my copy paste go this is kind of a weird thing to think about so we're going to start off just forget about copy paste it never really existed so instead you have a bunch of things called registers so if you think about copy paste copy paste has one register so you can copy stuff into it or cut stuff into it and put it back out thankfully this is not assembly registers no so we needed yeah it's actually pretty easy to use but in vim you actually have 35 of these things so on the one hand that explains why some of them's cut and paste commands are a little wonky but on the other hand you have a lot more power at your hands to do some pretty crazy stuff so you also may be wondering how do I paste something from the real world so if you wanted to copy something like say this and you wanted to put it in them you can do quote plus P quotes amended character means do something out of this register yeah do something to this registers so the plus register if you're using a Linux system running the xorg server is the X org global buffer sometimes it's yeah or asterisk there is also a second global buffer called star or splat as he's calling it sorry so if you're on a Windows machine they equate to the same thing if you're on a OSX or OS 10 machine they wait do the same thing if you're on a Linux machine there's a little bit of subtlety between the X or global buffer and the general global buffer but generally speaking that's an easy way to get stuff in and out of them now let's do them right all the registers you want yes also if you ever want to know what's in your registers you can do : re G and it'll show you all of your registers that currently contain text and what they contain or at least agree GG GGG GGG GGG that was a really accidental macro occasionally you'll find you hit the cue button and it starts recording a macro talk about what those are but you can get some wonky stuff in here buffers as a result another thing I wanted to comment on here is have you ever found yourself like typing something and then all of a sudden you want to paste something but then you have to go out into normal mode hit escape and then quote register paste to paste the thing that's really obnoxious so in insert mode you can actually do ctrl R followed by a register name and it will paste it as if you weren't actually in insert mode you can also just do control R and then quotes and that will place the anonymous register which is what you get when you just use y RP yeah so there's a lot of power here and with the control our command in insert mode it saves you a ton of time in using it it has pasting right yes it just doesn't have control R so let's talk about what some of these registers do so one through nine are your delete registers so anytime you delete something like the leader line it goes into one of these delete registers you can kind of think of these as a queue so every time you delete something it pushes something onto the queue and pops the last thing off so it gets added to one and then it goes into two so and so forth if you've ever ganked something and then deleted a line in order to make space to put something you may have been angry when you hit P and it didn't actually show up because your yank appears to be clobbered he actually didn't so quote zero is the yank register so whenever you yank something that's the Y command it puts it into the zero register so this is a really useful thing so if you're typing along you delete a section then you want to paste your stuff you can do quote zero P or ctrl 0 or ctrl R zero and it'll put the contents of your previous yank it's really useful in a great way to avoid the groups that clobbered my yank problem so the A through Z registers are very similar but subtly different so a through Z are the named registers they're kind of general-purpose you have 26 of them they're for general purpose registers if you use the capitalized version of those registers what that will do is it will append to where you previously type stuff so for example if we wanted to add something to s we can put this into s with quote capital s shift Y and then we can do a quote SP and you'll see that it had everything that I had previously plus the contents that I just yanked so we'll go and put that on a new line let's just so it's a little bit shift why is the ank the whole line yeah it's really useful so just a small demonstration that yes there's are a lot of registers we're going to cover them very quickly so if you've ever searched for something and you want to paste that someplace like for example let's say you've used the star key to select the word that you're currently having the cursor on and search for different occurrences of it and then you want to do a substitution or do something based off of what you've just searched for you can use quote forward slash and it will paste the contents of your last search so really handy when you start getting into what's called come in but we'll talk about that a little bit yeah we'll mention it in a little bit so another thing to keep in mind is quote - so if you do something like a a deletion that happens within a line like an X like an X or a DA W it doesn't usually go into the 1 through 9 registers it actually goes into what's called the small delete register it's just a quirk something you should be aware of so how many times have you been coding something you needed to add something up really quick okay well Austin's just weird so if you find yourself needing to do some inline multiplication you don't feel like multiplying 675 by 13 you can just do a ctrl R equals and then it will place the value of that mathematical result in line 4 and how advanced is that we hands so it will handle basic arithmetic operations it gets choked on floating points though so avoid floating point numbers yes and if you other bases can it do other bases I don't know I would look in I would do : H take a look quote equals innings or just try it so there's also some other things like let's say for example you have a large section of text you just want gone so you'll find that if you start working with really large text sections and you're deleting them because it's putting them into those registers 1 through 9 it kind of starts then starts to bog down a little bit because you have all of this memory allocated to storing this text if you really want something just flat-out gone you can yank it into or you can delete it into quote underscore and then it's gone forever now you mentioned the robber got cut off on delete slash cut whatever the deletions are usually just actually cut honestly because they get saved yeah with the exception of deleting to that specific register so something to be aware of yeah so one last set of registers that we want to talk about so quote : is the last e^x command so if you ever find yourself needing to modify a previous e^x command you can either use ctrl n or ctrl P when you're on the command line which is what you get when you hit colon or you can just do ctrl R colon and it will put the contents of your last X command if you ever want to paste the same text over and over again you can use quote dot if you want the name of the current file you can do quote ctrl R percent and it will give you the absolute path of the file that you're working with you may not think that that's super useful but it's actually more so more useful than you think also there's something called yes rusty yes that's only in normal mode so if you're in insert mode okay it gets the additional functionality of having that kind of yes so what I would look like I unusual thing and I actually want to forward from so you've undone something and you want to go back to the next the thing that you undid or okay so in normal mode you will undo stuff ctrl R will redo that that it unstuff however there's another feature we're not going to be covering today them actually keeps what's called undo and redo trees so it actually keeps track of all of the different versions that you have isn't that great what yes you would also like there ways to go back to like five minutes ago I only have five minutes from now once yes great yeah go over I mean if you went back already bunch willow it opens up everything that you've ever done it lasts like little cycle to the last open flowers now there is another thing I want to introduce can go back to them and the file name you just pasted if you're over a file name like this I think then you can type G F and a little net file so they credit write the name of a different file like bachelor season gyah there you go isn't that great yeah but I they different buffer or yeah yeah yes you can actually there's options that you have it opened up in different places also but by default opens in a new buffer it's a lot of black yes and we don't know you can mark okay so there's also something called an alternate file that's generally speaking the last file that you edited so if you're kind of going back and forth between two files and you need the name of the other file it's in quote pound or quote octothorpe if you're a typesetting nerd so if you ever want to know more about registers which are yeah : H registers alright let's talk about macros finally no more registers macros are doing that thing again that I just did because it was cool now there's a dot which is a short macro operator and for doing the same change that you just did so for example if you delete a work and you want each meeting words of you don't know how many then you can keep hitting dot and it will continue to activate the change of just made it won't do movements so if you peg J and then delete a line for example and having got won't do the J and it was declined so that's a really cool thing you can do if you want to just keep doing the same change now that's not really advanced enough for if you want to do a complicated series of things too so in that case you probably want to record a macro so that you can have a history of a series of commands that you can replay over another series over another line or something so you start recording a macro by hitting Q and then the name of a letter which actually records that series of commands into the letters register that's pretty cool actually because then you can paste out of that register and you can see the entirety of the command you to enter so you can edit it change around so Roberts going to make a new an example I did already want our amazing animals to do it again because I didn't see it recording you'll see this recording thing was there for a second when you're recording and once you finish recording you hit cue to stop recording then when you want to reply a macro you type the @ symbol and then the name of the register that you want to play out probably did macros are really cool if like I said you have a bunch of lines and want to do something similar to or you need to do something that can be the exact same sequence of plans I could involve some things about the text itself yeah get it put back so those are really useful okay okay so enough about macros let's talk about managing finals I was really confused when I started using BIM because it had these things called tabs that were not like tabs it's a lot tax return so there's a pretty straightforward system of editing multiple files in film at the very bottom of the stack is buffers buffer is just wait a little bit tax on those are buffers I'll get more of those in a minute on top of buffers those are windows windows and you look at buffers you've seen before that Robert has multiple panes those are actually just windows this is a window that's a window brings up many more the more windows there is oh you can do all sorts of cool stuff with windows open papa and at the top is tax tabs like I said or not like the tab file browser or whatever they're actually just a container or set windows that in that way I don't know probably can get anything up but it's a way to switch between already defined setups for window layouts so you might have like a tree files on one side a list of important symbols some scratch paper icon and another tab you could have just text and that's pretty useful once you get the hang of it but it takes a while because the ads are so firstly let's talk about spend more specifically buffers cutter chocolate lists echo those commands at the bottom there they're just for applying a set of commands over bottom and over every for something the more importantly buffers like I said they're just a window into a file then like remembers every file we've opened unless you explicitly tell it to get written so you can take a look at all the buffers you have open with : LS let's you'll get this list right now Robert has a couple of nameless buffers that don't represent any file he has that lorem awful thing HTML pages VMRC those are everything has open and this is where he's at in the editing room now that's that's great they say how do I actually do that become cycling buffers with some pretty basic commands : VN taking to the next buffer : vp with the previous one you can also switch quickly to the alternate file if you mentioned a second ago it's usually just the last file you edited with control caret I actually had fun that about that exchanges to this thing oh right of course now there's a neat command called : b which is short for de-spawn buffers right after that you can start typing out to a space you can start typing out the name of a file you have open and it will Fuzzle e autocomplete it for you so it's pretty smart if you know we probably want to go to you just type in : d space name of file new tab completion to is even the type of the whole thing that's produce yeah and if you ever want to be sure where it's actually going to take you you can hit tab that's not the file that it wanted to thank you to but another file you can continue to hit tab and it will bring up all of the matches that match that particular fuzzy match okay so onto windows it's not just an operating system anymore windows are as I said using two buffers they're actually pretty simple to use with they're complicated to master because they're Brazilian different commands and gluing them around all sorts of stuff it's incredibly easy to be confused as I have many times but the most basic commands are going to be for one there's control W is the prefix for pretty much every keyboard based most of them have : command based brother but generally you can do everything we control W with some feed my favorite is control WC which will close whatever window you're in right now that's really helpful if for example you're trying to help it brings up another extra window somewhere and you're out of school if you hit ctrl W and then W again will cycle through windows is between them you can also use control W in a direction up in the building direction you can do control W and to make a new empty we go as empty buffer excited it you can do control WS to for horizontal split vertically horizontally Soyuz ah yes horizontally split a window so if you're looking in the same file again it's not a copy of the same file it's actually the same so you can look at the top and control WB's what's birth these things are listed in slices and help I think that's it for Windows yes windows are probably the most important and trying to get used to type recovers tabs I almost never use because I never get that indented to having specifically often things but it's still useful and oh they are they are way ahold of a collection of windows you can go to the next to the previous with the genie T and capital T respectively and that's pretty much it make a new one with : tab new to rearrange everything to your liking so previous tabs so I think it was all pretty set now Robert mentions some syntax coefficient okay so let's say you have some C file that you want to edit and you find yourself typing something and you're like oh I want to make some change to none to guess so you can start typing num but typing that takes a long time so you can just get control in and it will autocomplete to the end of the line if there's multiple options it will let you alternate between the options you can go up and down through the different auto completion options with ctrl n and ctrl P so that's simple completions however there's also what's called omni completion so if you're using one of the languages that support it you can use Omni completion so if you're typing something in C you can do a control egg yeah it will do different things based off what your syntax completion is set up to do it has very different behaviors depending on what specific language you're using and it's actually kind of a pain to set up but once it's set up it works like a charm then we'll learn how to autocomplete anything that it has syntax highlighting for so you can start using different syntax completions for that some other different completions that you should probably know controlling yes would be control X control F for filenames so so then we can cycle through all of the files in this particular directory if we want say definitions of words so for example let's say we're putting in a comment and we're trying to remember how to spell explore because we're having a really bad day we've been typing we can actually cycle through all of the words in bins dictionary until we find the specific one that we're looking for you can also do control X again to have it go back and try a different type of matching so another thing we probably want to mention would be tags so how many people know what C tags is okay one person we will go over C tags later in the presentation so I'll cover that more than that keywords so keywords or anything that then will syntax highlight by default so you can take advantage of that in order to do syntax complete stuff control X control L is for completing lines you wouldn't think this is too terribly useful but if you're writing markdown and you don't like using pound signs to indicate headers it's actually really easy to use line completion to put in those headers that you want so if you could do stuff this is a test more stuff foo bar and then we want to put in a new heading two we can do control X control L we can type two of these control X control l and it will autocomplete to the matching line so it's not useful in every language but if you have a specific line that you're trying to copy it could be very useful like everything else in the syntax completion it will do fuzzy matching so pretty useful to have your toolbox some other completions to know about our thesaurus completion this is another one of those ones that you have to set up in order to use it you have to give them a thesaurus file Project Gutenberg publishes a good one mode that's in the correct format that you need so just grab the source from there dictionaries will pull it out of BIM spelling control X control S will cycle so if you have something that's incorrectly spelled and you want to correct the spelling control X control S will go through the different spelling suggestions for you which is really nice without having to go into this spelling change mode yes fin does do spelling correction if you didn't know that so like we can show you that in the presentation lastly you can use control X control V for Vendetta ting your vehm are see you can use control X control V to complete different vends or if you're in command mode and you're trying to complete a bunch of different than commands you can use control X control V to also do that okay now let's pretend that you're going to get a job as a dad and you need to write up a letter including the word resume and if you're weird like me want to include the e with little accent on that's where digraph trees gone are the days of alt codes where you have to type in all something rather go to Google and copy the whole back forward instead you can if you're insert mode type ctrl K and then combination of two letters to get what's called a diagram it will automatically turn into a bold letter that actually is something you can only type so as an example if you're if you need that key you can hit an insert mode ctrl K E and then the accent character probably the forward ' and there you go say what yeah it's about a possible price yeah yes but the right symbols what you're looking for you can get a whole lot of symbols like this in the in the presentation I put the Omega character that would get all sorts of stuff there's a huge list in Health eyebrows so if you ever need to if you ever need to put in a special character that's that's the way to go of course digraphs can really insert for example a little tab character unique in that case you can from insert mode type control e and then whatever character whatever you hit next will be inserted literally I use all the time put it tabs and also do I think backspace or line breaks what we need so if these been special characters he's dead so I'm going to very briefly mention a concept called templates and a concept called abbreviations for me personally this has been replaced by another feature that Austin's going to talk about in a few minutes but if you're one of those people who doesn't want to have a ton of plugins in your particular programming setup let's say you're in a contest environment where you can't necessarily download your plugins for your text editor this is a good thing to know about so on from the command line in vim you can say : r and it will read in a file so what you can do is if you're editing for example a C file and there's a standard template of stuff that you want to load into the file you can do 0 so at before the first line read in the path to the template and that will put the entire contents of that file whenever you start a new document so as if you're in a contest environment or something like that where you need to basically set up a template and have it consistent on each file that you're using can be very useful another trick that you can do is block this on something called auto commands we're not going to be covering those today but something to look up if you want to make this specialized for file types or something of that sort we're also going to talk about how to do some quick snippets so you can do : a B which will let you view your current list of abbreviations so I don't have any abbreviations but you can do : a bee stuff and it will actually do abbreviations like stuff if you are like me though you want a little bit more power in this so if you're using a plugin that I very recommend called ulti snips and you want to insert I don't know like a main function in C you can type nain tab and we'll go ahead and autocomplete all of that for you it's a useful little feature to have so any questions about snippets a lot of the views that people use it for is let's say you some misspelled a certain word a lot you can use abbreviations to just kind of like the autocorrect feature in Word to just fix it as you're typing so you don't have to go back and correct that specific word all right so Robert mention that there's a plugin that he uses what are plugins there are a whole lot like the plugins are stuff you can get for other text editors like text me sublime text but in this case also in Rome's case you can get these things magical things that are both plugins maybe other people have been community to add extra functionality and new cool stuff like better commands into them that didn't previously have there is a plugin called a bundle that will manage your plugins 40 it's kind of meta weird this is a list of all Roberts installed plugins and a nice thing about the plug-in bundle is that it looks at this list and checks to see if anything needs updating or installing or changing whatever and it handles all of that form it has very good documentation so if you're getting into plugins I definitely recommend you check it out what happens to it in this plugins live in your doc Tim folder in your home directory now a lot of times if you're dealing with plugins then you'll see this thing in key commands called the leader and that takes a while to figure out what the leader he needs is a user set key that you can prepend to a lot of to whatever key commands you wanted to so that it'll it won't overwrite any pre-existing mats now we can set up your own commands that are based on pluggin actions and stuff I set my leader came to be space some people come up it's a pretty weird thing but once you get the plugins no videos to appear the other thing is by defaults backslash right not two backslashes is the presentation yes there are tons of plugins I have about 20 installed tonight here's some really useful ones we'll have a link to a website that has even more dirt really style file list kind of like it's blend text your text make looks like that it's pretty powerful sin tastic is for syntax checking and things that can be syntactic technically Python it's kind of like a automatic lender and use those before Robert break something so apparently my see syntax checking is broken isn't working that happens a lot to fugitive get interaction if you got that job because you're cool and smart and you need to do version control then picture ship is gone you're back it's a really cool rapper for film for doing kid stuff Robert my book like automatically you can add stuff and commit things do whatever that was I'm scared surround is another one of my favorites it will allow you to edit surrounding characters so for example if you have thing in quotes you want to change those books to similar books or backticks then you can very easily just change it with single or hair keep kickers so change those to something else inference okay I'm forgetting the prefix first surrounded CS and then quotes and there you go there you go so with only 30 seconds of computing he was able to change those books from two parenthesis once you get used to it goes long yeah I don't use surround as often as he does it's really helpful if you're editing HTML if you're not doing a ton of HTML it's has different usability I really like it it makes me feel cool so moving on there is ulti snips and vim snippets Multi snips is a snippet engine Robert just introduced it because it's really useful snip that Vince divets is a collection of default snippets that adds a lot of really useful things for most programming languages Tim Pope is a major contributor to the vim scripting community yeah and pretty much gonna general he made fugitive and surround and a bunch more anything he makes is going to be produced now Roberts going to go back to color base okay so ctags is a program it's been around forever but what it does is it essentially scans your code for certain attributes like variables function names if you're in a program object-oriented IMing language it will scan it for class names things of that sort then it will record these things in what's called a tags file so what C tags will let you do is if you have a particular bin or a particular set of code that you're editing in them and you want to see where stuff went let's go over to our fubar example you can actually keep track of a list of functions and stuff in it I'm using a plug-in right here to kind of show this off so you but essentially it'll keep track of all the different functions you have and then as you add additional functions normally this window does it take off take up half of your working space yeah and then we could go out of them for just a moment and then we can do a ctags of who you are dot see and you can resume and if we look it'll add food to our list once you have the tags file created VIN will edit the tags file as you're editing your program and we'll start actually keeping track of the changes and stuff that you make to these tags it's really useful keep in mind you will need to if you create new files in the directory you will need to add those protects directory you can use bash blobbing in order to do all of that if I had thought for more than a few seconds about how to do that I could have also done : bang ctags star C and that would write run the command and then pop me right back into that after I'm done using a colon bang the explanation point can will allow you to just run any shell command from inside of it giving the output in that nice little window it's precondition to not to ever leave you can also do things like filter so if you want to do like percent bang och and run an ox script on your vim code you could do something hideous like that but it's completely an option so just kind of keep in mind filtering and then kind of the shell xscape as two easy things to do there if you have let's call foo right here yes so you can use ctrl close square bracket and it'll actually jump you to the definition of the function so let's say this is in a much less convenient place like this and we want to jump back to it you can use ctrl close square bracket and we'll take us to the definition of that which is function below close square bracket close the really awesome thing is if you have your path set up properly and you have C tags set up properly the controlled tag or quote control close square bracket will actually take you to whatever file that function happens to belong to so if you're like debugging a ray tracer which has 54 jillion functions and seven or eight different files and you have no idea where that function is defined control square bracket will save you a lot of time in finding it once you've jumped over to that function you need to jump back it's just ctrl T and it'll take you back to wherever you jumped from so if you want to think of it like a programming stack it works a lot the same way there's also another program called C scope C scope is very very powerful but it also has two limitations one it's exclusively for C or C++ it does not support any other languages and the person who maintains it has known ancient of making it support other languages but the other thing is because it's a little more syntax heavy it's really only useful for really large code bases but for example this summer I had a I worked at a job where we had we had programs where we had several million lines of C code and if you want to find a specific functions C scope will actually find that function for you give you the parameters for it it will let you do global find and replace so if you're used to eclipse and you have that you like that nice little refactor thing C scope will actually do that for C and C++ code so if you ever find yourself editing large C applications C scope is invaluable for that any questions about C tags or C scope one other thing I wanted to cover really quickly is using them to test faster so if you find yourself writing a bunch of code there's my synthetic track by the way so it finally showed up so if you find yourself editing a bunch of them code or C code and/or pretty much any other program and you want to start testing it you can do : make and it will actually execute your make file so I'll show you the make file in a second but you also notice that came up a little error right there so you'll notice let's go to the top of the file you make again you'll notice that I'm back down at where the error was so by default whenever you execute make as call and make it will take you to whatever line that particular error was if you had first yes and you can use : C open it'll actually give you an explanation of what changes need to be made and where if you have a bunch of problems with your code so we have three errors generated can do I believe it's closed brackets see did I say it was brackets 'i will take you back and forth from the errors in your c file so you can easily jump through and fix these different problems so if we fix this add our semicolon you make write make and you can pause the code for us and then if we want to test we can do : bang and then you can do in this case dot slash fubar and this is a guessing game so there we go and you can test your stuff from within them so I said I was going to show you that main file so I'll go ahead and show you the make file pretty simple if I was thinking about this a little bit more probably would throw in a make test in there that way I could have just done make test and it would have allowed me actually let's go and do that and have test depend on the fubar five so obviously I had a slight problem there but essentially that's the idea so some other commands that I showed off CN will take you to the next problem that you had CW will bring up the list of errors that exist C open will open the window in what's called a quick fix window so it's an easy way to look and see what changes you need to make to your code in order to hit it to compile and lastly if you don't want to remember control Z as a quick way to get out of them and then pop right back into it you can also do colon she'll do your shell commands in your shell and then pop right back so we are back to our shell when we exit we end up back into them so any questions there all right so these are a bunch of commands that we just thought are cool and we didn't have another place to really put them some of my favorites are GQ and an emotion to word wrap that line or that paragraph or whatever you want so that'll figured in any character or 90 character what have you found reading so useful for Python for example v and capital V and the control will be are both for visual mode stuff we saw that we explained briefly before it's for editing weirdly shaped punches of text it's pretty useful check out health visual mode so people know about it the colon enters the command line there's a whole bunch of powerful stuff that you can do that we didn't cover hardly at all so you can do help column there and one thing I just remembered if you're in normal mode you can use control X and control a to decrement and increment the numbers that your characters apply you should see them down once he finds a number you support it so control a goes up control X goes back down it's automatic like if you have a hundred 101 to go back down to 99 single first it's pretty smart doesn't work and that actually just about wraps up what we have the plan that was a lot of material and I think I'm exhausted as you guys are we'll put this presentation out in an email so you can see anything you might have missed where you actually recorded it at this time yes these links are all very useful especially well know I look slightly also if you have any questions feel free to ask them come talk to us we'll be like I said sending this out to be mailing list if you're not on my list I would like to be also popular talk to me go briefly to this list of resources that we have here so you'll see two resources by Drew Neal one of which is practical bin that's a book comes on dead trees it also comes in an electronic format it is an excellent book it's a collection of about 40 min tips that changed the way that you think about them and how to do stuff in BIM and it can be really efficient I actually found it a quite interesting read I read it over Christmas then casques is basically a video summary of a lot of the tips that he has in his book but there are also tips that are not in his book and tips that are in the book that are not in the thin casts so if you're more of a visual person you want to see it done this is a great place to look if you ever search how to do some random thing engine you'll probably see them in tips wiki show up it's very useful another place you can look for that kind of information stackoverflow we mentioned bundle I use it I cannot recommend it highly enough and then Austin also recommend something called them awesome so you want to speak about it awesome is just a website that catalogs kind of different plugins that smaller is to say about it so thank you for your time in closing questions once place okay
Info
Channel: Robert Underwood
Views: 54,640
Rating: 4.1026616 out of 5
Keywords: Vim (Software), Clemson University (College/University), Association For Computing Machinery (Membership Organization), Seminar (Type Of Conference)
Id: v0W7JkzQAzA
Channel Id: undefined
Length: 64min 34sec (3874 seconds)
Published: Sun Feb 22 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.