 Okay, so I think we're long overdue for a VimTips video. So in this video, I'm gonna not so much show you one particular command, but a general workflow, a general problem I had that probably can be extended to a lot of the stuff that you might need to do. So to give you the background, this is something I did a couple months ago. A professor wanted me to create a website for him, which is simple enough. Except for there's one particularly difficult thing he wanted me to do. That is, he wanted me, he gave me a huge zip file of hundreds of PDFs. And this is actually what I have here. So I have many, many PDFs here. In fact, if I want to, let's count them up. We have 216 of them, or well, let's actually look at the PDFs we have. Still pretty, not PNG, PDF. We still have 120, or excuse me, 182 of them. So basically what I had to do for the website is create links to each of these articles. Now you could do this manually if you wanted to waste a lot of time, but it's easy enough to do in Vim. Of course, you can also do it with the regular expressions and stuff like that. But in Vim, it's a little more intuitive. So I'm gonna show you a workflow for the stuff I need to do. So I need to create links, HTML links to each of these PDF files. And I also need to basically manually go in and read the article title so I can name it, which we can actually still facilitate with Vim. Even though there's no way, a lot of these, we're not gonna be able to actually have some kind of command that reads each of these for a title. That's just not possible, given that they're all so different. But anyway, let's go ahead and get into this. So how are we gonna approach this first off? Now I'll go ahead and open a Vim file, or file in Vim, and I'll call this list HTML. So this is a new file. Now the first thing I wanna do is actually read in the names of all of those PDF files. And that's actually easy enough to do. Let me turn on screen key so you can see what I'm doing. I'm going to run the command read. So just colon read. And that can read in the output of any other command. So you can give it a bash command with exclamation point. And let's say I want to choose ls, all the PDF files. And if I run that, what it actually happens, it runs ls and it puts all of the output right into Vim. So here we have all of our file names, nice and convenient. So we don't have to do any copying or something like that. That's a waste of time. So anyway, that already gets us at least a third of the way there, right? Okay, so what we wanna do, let me take the first one here as an example. Here's generally what I wanna do. So I want to have a link that looks something like this. So href and then the name of the PDF. And then the article, title. This part I'm basically gonna have to add in manually. And then I'll close the link, okay? That's basically what I wanna do. Now so how are we gonna approach this? How are we gonna do this? There are actually lots of different ways to give this syntax to all of these different file names. It's actually, there are many different options. We'll go through a couple of them. So one of them, I don't know if you know this, but Vim has a command called norm. It is a command that you can run in the command line. But it basically runs a normal mode command. Like it literally just types out that sequence of keys. Now that's useful because you can apply it to many different lines at the same time. But let's start with just one line. So I'm gonna run the norm command on this line right here. And I'm gonna run capital I, which of course goes to the beginning of the line and enters insert mode. And then I'm just gonna type in what it literally types in. So href and then open the quotation marks. And if I type that you'll see that it actually adds this stuff in. I can also run norm again. And let's say I wanna do capital A to add to the end of a line. And I wanna add in close parentheses. Then I'll put in a placeholder for the article title. And then I'll close the a tag. Now if I run that, what's happened is we have done the same thing we've done up here. It's set for with a command that we can run potentially on multiple lines. So let me show you how that works. Now what we can do now is I can go to these lines we haven't played with yet. I'm just gonna select them with capital V and I'm gonna go all the way to the bottom. And what I can do is actually run the norm command in the same way that I just ran on that other line. So I can say capital I, href equals open quotes. So now we have all of the top, or excuse me, the front portion of this all typed out automatically. And I can do the same thing again, just run another norm command to finish off the other side of it. So if I type in, I think this is what I put in before. Did I not do that? Oops. I forgot to put in capital A. So if I type in, yeah, okay. So now we have totally completed, we basically have all the syntax we need for the core of the articles. We can pretty much copy this into whatever we want. The only thing left is how are we gonna get the article titles. Now I've put placeholders here. I am one of the people who map like space space or space tab to automatically find the next one of the sequence and go there, delete it, and then put me in insert mode. So I can easily jump to each of these and name them if I know the name. But how am I gonna figure out the name of these files? Now I could check them all manually. That would be a big pain. But one thing you can do in Vim is I can actually tell Vim to open this up for me, open each of these files up for me. Now keep in mind I'm in the same folder that all of these articles are in. So I can run an external command that opens them up. Let me show you just an example of that. I mean, let me do one of these manually. So let's say I have this file name here. Now if I open, if I go to the command section, again type in exclamation point for a bash command. Let's say I wanna run MUPDF, MUPDF is my PDF reader. It might be different for you if you have events or something else. So I'm gonna run MUPDF and I can type in, you know, 1969 underscore syntactic.pdf and if I type that in, it's gonna pull up the PDF. But we can actually automate this process with a couple changes. Let me actually write this out. So let's say, let's map this as if we were writing in a VMRC file. So I'm gonna map the sequence leader P or something like that. So that's gonna be backslash P on the default, mine is gonna be space P, whatever you set your leader to. And what I'm gonna have that do is basically this. If I'm on a line and I want to open this file, what sequence of characters do I have to press? Well, let's say I go to the beginning of the line with zero and then I yank what's in the quotation marks. So we'll do zero, yank in quotation marks. Actually maybe I should do, yeah, we'll just sit with that. So yank in the quotation marks. And then what all we can do is just run the command that we just talked about. So MUPDF, space. And what you can do to paste in what you have in your buffer is CR, and I think you just do quotation marks here. I'm not entirely sure. We'll find out in just a second if you're pasting from the default buffer. So that's gonna paste in the file name. And something else we might wanna add since the bash command is disown, ampersand and disown. And that's just so we can continue using them and the PDF will be separate. And then we can just type in enter, enter. So this right here, this seems like a lot of work but it's about to make things a whole lot easier. Because what we can do is, I'm actually gonna copy this thing in right now. So we'll just yank this. And then if I put this in the VIM buffer doing control R and then quotation, that actually will run this. So now we've run this command. And now we should be able to actually use this binding now that we've sort of bound it in VIM. So let's see if it actually works. We'll find out moment of truth. So if I press a leader in P, well it actually worked. So we have the PDF now pops up. So I can go in here and which one was this? This is the syntactic one. So I can say syntactic structure modifies, you don't care. So I can close that out. I can go to the next line here or I can type in leader P and get what I want here. And I can see the title here and type it in. So we'll say some theoretical and empirical blah, blah, blah, blah. So that's the gist of it. This is sort of, you can tweak this just to make it extra easy for you. Actually I should probably delete this line. It's just for illustrative purposes. But basically this is a kind of a setup that you can make in real time to get what you need to do. And open up files if I need to play around with them. Read them and do what I need. And the original process which was really difficult of making the syntax for all these different files and all these different links. And then otherwise I would have to manually open everything. We also sort of simplified that. So even if you have something you can't necessarily do in Vim, you can make it a whole lot easier. So that was some of the points. So anyway, this is just basic stuff out there. So I hope you enjoyed it and I'll see you guys next time.