Files

452 lines
22 KiB
Plaintext
Raw Permalink Normal View History

Episode: 3966
Title: HPR3966: Vim Hints: 006
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr3966/hpr3966.mp3
Transcribed: 2025-10-25 18:04:50
---
This is Hacker Public Radio Episode 3966 from Monday the 16th of October 2023.
Today's show is entitled Vim Hens 6.
It is hosted by some guy on the internet and is about 25 minutes long.
It carries a clean flag.
The summary is, various contributors led us on a journey of discovery of the Vim and
by editors.
You are listening to a show from the Reserve Q. We are airing it now because we had free
slots that were not filled.
This is a community project that needs listeners to contribute shows in order to survive.
Please consider recording a show for Hacker Public Radio.
Hello and welcome to another episode of Hacker Public Radio.
I am your host, some guy on the internet.
Today we are going to be doing a quick little Vim Hens episode.
We have a series here on Hacker Public Radio called Vim Hens and this is going to be included in that series.
So let's get started.
First thing I want to do is talk to you about my Vim RC.
I am not going to explain all the elements in my Vim RC is going to be in the show notes.
So you can scroll down and you will see a little section of my Vim RC down in there.
I have it pretty well labeled so that is why I am not going to explain every single element.
But I will just touch a few of them.
You will see now I have set number relative number.
That is one of my all time favorites right there, the relative number.
Very good.
Also like setting column where you get the color column.
You can see mine I have it set to 80 and then I have the column set to magenta because I normally use a Dracula theme.
Or in this case I am on Papa West and that magenta works really well with Papa West.
Definitely got to set the no wrap.
I do not do line wrap.
You break line but you do not wrap line.
And if it is coding on top of which like if you are writing any kind of code or scripting or anything like that.
You should never be wrapping any kind of line anyway.
If you are going beyond column 80 you need to be brought into a meeting.
That is just the way it goes.
Somebody has to bring you in.
I am not saying die on that hill if it happens to be 81 82 something like that.
But the idea that you are going to wrap line while coding.
Absolutely absurd.
Right underneath there is another one of my favorites.
I got to set list.
Now that one is combined with set list characters.
And you can see I have the characters that I like to use when I am doing my set list.
All that is is the invisible characters.
You normally do not see like white space.
End of the line character.
So it is technically not a carriage return but it is that symbol that lets you know that this is going to be a new line.
Those are just the symbols that I have for that.
Because I like seeing these things.
And then at the bottom I show you the toggle that I have for that.
That is how you enable it.
And then you can set the characters to whatever you want.
And this is very helpful because there are certain documents, XML documents and things that I pull down.
Well, some of them are just text documents where they will have a mixture of tabs and spaces in the document.
And this allows me to quickly see your tab.
Now if you are going to set this up.
Your tab character has to be at least two characters long.
So you will see with mine I have two of the actual bidirectional arrows for tab.
That is because it has to be two characters.
Now you do not have to use that bidirectional character that I am using.
Which is typically the printed on the tab key.
You can use anything for it.
You can use the add symbol if you wanted to.
But you are going to have to use two of them when you are specifying tab.
And if you do not you are going to get a nice little error.
Now I am thinking about turning the visual bell off.
I thought it was going to help train me to be a little bit more efficient in them.
But I think what it is actually doing is blinding me.
Yes, so I am thinking about having to turn that off.
I commented out the auto indent and smart indent.
Because with some of my custom things that I run in my custom sessions.
That was beginning to be a problem.
It is fine to have it when you are coding.
But when you are doing mark down and dealing with show notes and stuff.
Yes, that was beginning to be a problem as well as other things that I do with mark down.
I am not prepared to talk about those other things yet.
But I was just explaining why you would see set auto indent, set smart indent and set smart tab.
As commented out in my VMRC.
There is some other basic stuff down there at the bottom for setting up your directories.
For your undo and things of that nature.
I believe episode one of the VAM hints.
Talks about that or maybe it was episode two.
I can't remember but just check out the VAM hints series.
You will definitely pick up a lot of wonderful tips.
I ended up discovering the VAM hints series after I said everything.
After I went through the trial and error.
Lots of duck go.
Now we are at the fun part here.
We have some normal maps going on down here at the bottom of the VAM RC.
You can see I have silent on them because I don't want the little messages popping up at the bottom.
That's all that does is you get the message that shows what you're doing.
So we got the control L is the first one for no highlight.
Shout out to Dave Morris and Archer 72.
That was super helpful.
I'm glad to have that because it was super annoying.
Whenever I would be doing searches and things or running rejects.
And there would be highlighting on this crap all over the place.
And I'm like, oh my god, how do I get rid of this?
And then I'd remember.
But then I'd only need it for that one time when I'm doing it.
And then I'd forget it the next time I needed it.
So it was good to just pluck that right on in the VAM RC.
Yeah, Dave told me he matches his to control L.
So it's just like when you clear your terminal.
This is clearing highlights in VAM.
So that's the idea behind using control L.
Now I got control S.
Most people would think control S for save document.
Well, we don't do that in VAM.
All right.
That's taboo.
You're not saving document with control S in VAM.
I mean, don't get me wrong.
You could do it if you wanted to.
But I just choose not to.
I think of it as dropping down to a shell, you know.
Now you could do when you drop down to a shell in VAM.
You could do SH, right?
Command SH or colon SH, colon is command.
So you can do command SH.
And that'll get you out of VAM to a shell.
You drop completely out of VAM to a shell.
VAM is placed in the background.
You get to the shell.
You do your job.
And then you do a control D, which then brings you back to VAM.
So after you're done running your commands.
I don't like to do that anymore.
Like when in the beginning when I was learning that was helpful.
I prefer term now.
What I do is I drop down to, well, I bring a terminal into VAM, right?
So when you run term, it'll split your screen in half.
At least on mine, it splits my screen in half horizontal, right?
Then I use control WX to swap the spaces.
So I have my work environment on the top and my shell at the bottom.
That's when I switch down to my shell using control W.
And then hit like J because I moved the shell to the bottom.
So I'm going to use J to get down there to that shell.
And then I use control W.
I'll run like 14 minus.
So type in 1, 4 and the minus sign or hyphen.
And that will reduce the size of my shell window by 14, I guess, units or whatever.
Whatever the measurement is.
Probably 14 columns or whatever.
Not columns or roles.
In other words, it's going to make the shell smaller and make my work area bigger.
So if you've ever used like visual studio code, you know how you can open up that terminal
at the bottom of the screen and have a little terminal down there at the bottom,
that's basically what I'm doing.
So I have a terminal at the bottom of my VAM session.
So when I want to run, like if you're doing Python coding and you want to test your code,
you can edit your code in the top screen, drop down to that shell that's always down there at the bottom.
And then, you know, run your code from the terminal at the bottom down there.
Now just be careful when you're shifting buffers because that shell will count as a buffer.
So say, for instance, if I only have that one buffer open and a shell,
if I do a buffer next, which is Command B and in my top window where my code is being edited,
it will then shift me to a terminal.
So you know, just you'll get used to it.
By the way, I'm not a developer.
I just play around with stuff and have a little fun.
And speaking of a buffer next, you see in there, I got leader, a left bracket,
leader right bracket for my buffer previous and buffer next.
So I can easily shift between buffers that way.
Now, if up sometimes when I'm working on like four or five buffers,
I'll just use Command B and the number of the buffer.
So you just run a LS and VAM command LS that'll give you your buffer numbers
where you are in your stack and then you can run buffer number to jump to that position
where you need to be in the stack.
That way you're not just buffer next, buffer next, buffer next, trying to get you know.
And I used to run tabs too.
I mean, tabs is fine if you like to have tabs, but when I run tabs,
well, sometimes I will in most of the time I won't.
So next, you're going to see the leader S O.
I had to add this because I was sourcing so many things so often,
like as I'm going into different work environments, right?
So you're jumping from bash where you're going to have your bash environment.
You could jump it from Python where you got your Python coding and all of that.
And then you got these mark down and then it might be the older mark down.
You're using a vanilla mark down and then you got the newer stuff that you're doing today
where I switched over to a pan dock flavor mark down.
You know, it was it was a lot to try and keep up with.
And you don't want all that crap in your and your VMRC.
So what you do is you create sessions and you need to have a place for your sessions.
And whenever you want to source your sessions, you don't want to be sitting there typing
in every single time command S O and then path to to session.
So you just put a leader in there, run yourself for a leader S O,
which is going to automatically put in your path to wherever your sessions are.
For me, you can see mine is just config VMRM sessions.
And once I run leader S O, I then just type in like the first two or three letters
of the session that I want, hit tab the auto complete enter or carriage return,
whatever you want to call it. And there you go.
We're we're already sourcing our new session and we can begin work.
Now right after you see F3, I got that.
Yeah, that's not a leader. That's just silent F3.
That's the toggle switch for the invisible characters that we talked about earlier.
So if you want to make white spaces and become visible as well as your your carriage return,
I guess, you know, it's going to be that end of line symbol and any other invisible symbols
like the tab symbol. Yeah, you can make all of that visible once you define
what those characters are going to be like I described above.
And this is a toggle command.
You can see the exclamation mark at the end of the set list.
So now every time I tap F3, I'm going to be toggling that on and off.
You know, if I'm tired of looking at it, which most of the time I'm not,
it just depends on what I'm doing.
If I'm tired of looking at it, then I can toggle it off.
After that, we got a couple leader CCs.
Those are going to be for my my column highlight.
So it's the color column. That's what CC stands for.
Yeah, I got a couple of columns that I want to maintain.
And it depends on what I'm doing.
Sometimes, especially when I'm working late, getting close to the no-sudo hour,
you know, I really should stop working because I'm with a higher chance of making mistakes and things.
I have had situations where I've run rejects and just completely blanked whatever work I've been doing.
And to kind of help keep me from doing that.
First of all, being able to visibly count the amount of spaces I'm looking at,
kind of helps, then dropping these additional columns wherever I need them.
So if I want to check and make sure I'm on the correct one,
and I just want to be able to just add a glance, look down the line.
You know, there you go.
So that's that F6 and F7.
Those are copying two and from the system clipboard.
I'm using VAMP.
All right.
I'm talking actual VAM, not NeoVAM, not any of the other, you know, people like to call everything VAM,
but I'm talking about VAMP.
So from my understanding, if you're using NeoVAM or GVAM or any of the others,
sometimes they built in interaction with the system clipboard where you could use,
what's that buffer called?
Not buffer.
It's a register.
It's those special registers.
I can't think of what they're called right now, but you get those special registers
that interact with the system clipboard.
And if you're using vanilla VAM, you don't have that.
So in order to interact with the system clipboard, you use a tool that interacts
with the system clipboard like Excel or clip, you know.
So that's that's how I do it.
Now we're going to run down here to leader 7, leader 8.
That's my turn on and off the spell command.
Because with this other thing I've been doing recently, I had to add that in there.
I'll talk to you more about it.
I hate to keep teasing about it, but it's not ready yet.
That's a show that's still cooking.
It's been cooking for a while now.
So now we're going to move into one of my VAM sessions.
This session is the main reason why I wanted to do the episode,
but I first wanted to go through the RC, the VAM RC to get you ready
to discuss the VAM session.
So we can run the leader SO, which is, as we discuss,
going to source something.
In this case, we're sourcing markdown.vam.
Now inside of markdown.vam, you can see everything that's there.
These are the markdown codes or not codes formula, you know, whatever.
These are settings.
I don't know what else you call them that I use.
Now that first one up there, you're going to see the abbreviation
to three star or asterisk, whatever it's called.
That's your vertical bar.
I mean, a horizontal bar in markdown.
When you need a bar, you just insert a bar.
You can see that leader 1, 2, 3 right afterward.
That's just to set up your bullets.
The F2 is a little bit special because it's meant to kind of strip out a bunch of crap.
There's supposed to be a F1 in there, and I owe their all the way at the bottom.
Okay, so there's an issue then, because I think that second F2 up there?
Yeah, there's a problem.
I think that second F2 was supposed to be coming, F3, and I forgot to change that.
So let me go ahead and change that.
That's supposed to be an F3 up there.
So let's substitute that for three real quickly.
So we got some live editing in the middle of the episode there.
So it's going to say F3 now for you guys.
The F3, whenever I'm, say for instance, copying stuff in for the show notes,
and like, I'm trying to think of a site, Wikipedia, right?
Wikipedia always has like these footnotes and things.
So when you're copying a paragraph in for your show notes,
it copies in sometimes these characters you do not want.
So I'm running a bit of rejects to remove those characters I do not want.
And this also includes those footnotes where you get like the left bracket,
some number in between, follow by a right bracket, and things that look like hyphens
but are not actually hyphens.
They're just like another vertical kind of slash looking thing.
I just want to get all those out.
Now I normally activate that using a, I need to fix that.
All right.
Now right after that, we're going to be looking down at our three headings or whatever they're called.
Yeah, I think you call headings or header, whatever they're referred to as your level one, two, and three followed by source.
When I'm building links, what I do is I put the label for the link on the first line,
the actual hyperlink itself on the second line.
Now while on the second line containing the hyperlink anywhere on that second line,
it could be at the beginning or the end or in between.
While in normal mode, I do a leader L2 or a leader L1, whichever one you want to choose,
and it will couple both of those lines together into a markdown link.
So that just makes it fast and easy when you're doing a bunch of markdown and stuff.
I first developed that when we were doing the New Year's Eve show,
it was not anywhere near as refined as it is now.
I think it was about like six lines long at the time.
But as time goes by, you reduce it all down to one, and it's much nicer and leader now, works much better as well.
Speaking of which, same thing for my Thunderbird.
I did an episode in the past about editing Thunderbird filters.
Remember that used to be four different steps that you would run?
I condensed it all down to one.
Maybe I shared another day or something, I knew I'm teasing.
Hello guys, this is a future editing Scotty here, editing the show.
I feel bad about teasing you guys about the Thunderbird thing,
so I went ahead and added the Thunderbird one liner down there at the very bottom of the show notes.
I also made sure to add a little note for you not to die on that hill,
because one of you are probably going to say something about that one liner,
and I'm just telling you right now, don't die on that hill.
That's not a threat, just in case somebody's wondering if you're not used to that saying,
this is just a bit of advice.
Before you decide to load up your keyboard and head over to the comment section,
just remember, I told you, don't die on that hill.
There you go.
Now back to our usual programming.
So you get that L3, it's just adding a link.
I probably delete that because I rarely reuse it.
You got your leader N1 and your leader N2.
Those are for swapping between.
I had to add those because I had two separate mark-down sessions,
one for a pan-doc style, any other for vanilla mark-down.
I was thinking like, man, there's really only subtle changes that I use between the two.
I need to find a way to be able to address those changes.
That is usually line breaks.
Whether you're doing a hard break with a backslash at the end of the line,
or the, I guess it will be the soft break with the double white space at the end of the line,
that's what N1 and N2, well, leader N1, leader N2,
through a visual, no recursive map.
That's what it'll do for me.
It'll clean up those lines so no matter which one I choose,
and I have to, you can see also on the end there after the bar,
and I start that next section with the dot V.
I think I got to take that dot off.
I can't remember what was going on.
During the testing phase,
something strange was happening where it was constantly wanting to apply this
to the entirety of the page.
I was like, no, no, don't do that.
Just stick with this one line for now until I get it working right.
It would not just do that even though I was in visual mode.
In visual mode, I'm having only one subtle line selected,
yet Vim was still trying to select every line on the page,
or every line in the buffer.
I had to put that dot there to keep it in place.
I finally got it working the way I wanted to.
I got to go and take those dots out of there
so that way I can apply this effect across multiple lines,
highlighted individual mode.
But that's for another time.
I'm not going to worry about it now.
At least you know what it is I'm doing.
Basically, if a line does not have a break on it,
meaning a space, backslash, or a double space,
that's the break.
It will add a break based on whatever selection.
So in one, we'll add the hard break,
which is the space backslash.
In two, we'll add the soft break.
And I choose in because it's new line,
like at the end of the line.
And in Vim, if you're selecting end of the line,
it is backslash in.
So that's why I just chose leader in for this thing.
That's my reminder anyways.
I know I know a lot of jibber jibber happening at the moment.
My mouth is getting super dry too,
so I apologize for the mouth noises if they're happening.
And you can see at the end,
I just throw on some know highlights as well,
just to make my job easier.
Then the way doors are built,
if the line does not have a break on it,
this will add the break.
If the line has the other type of break on it,
it'll convert it to the break that I want.
So if it has a hard break,
it'll convert it to a soft break,
because that's the one I want.
And say in vice versa,
if it has a soft break and I want a hard break,
it'll convert it for me,
because that's the one I want.
It just makes doing your markdowns so much faster and easier.
And again, you don't want all this jibberish in your Vim RC, right?
So that's why you put them in custom sessions.
And I guess, you know,
when you source your session,
it's a lot like adding a plug in,
except it's all homegrown, right?
You just source your session,
and you do your thing.
And it's customized to just what you want to do.
C1 and C2, those are simple code blocks, right?
You're adding code blocks, things.
The F1 and F2,
those I don't use as much anymore,
it's mainly when I, again,
when text starts to sprawl beyond line 80,
column 80, excuse me,
I have this set up with a format,
the width of that text,
into range column 76,
to prevent the line from going everywhere.
But I don't use it as much anymore,
because when you upload the hacker public radio,
a lot of that's taken care of for you.
Yeah, so that's just the F1 and F2,
simple formatting,
and move on down to the next control B,
that's for creating bold text,
and control I,
that's for creating italics.
Now that's it for what's in my markdown.vm.
I've already told you how you get it.
You know, you just source it,
and I got an example of how to source it,
using command and so,
even though it's also up above
in the VMRC up there,
there's an example up there.
Nonetheless, I hope you enjoyed the episode.
If you got any questions,
leave them down below,
maybe do a show,
you know,
telling us what's in your VMRC,
include it here in the VMHintz series,
and I'll catch you guys in the next episode
of Hacker Public Radio.
Thank you for listening.
Take it easy.
You have been listening to Hacker Public Radio
at Hacker Public Radio.
Today's show was contributed
by a HBR listener like yourself.
If you ever thought of recording a podcast,
then click on our contribute link
to find out how easy it really is.
Hosting for HBR has been kindly provided
by an honesthost.com,
the internet archive,
and our sings.net.
On the Sadois status,
today's show is released
under Creative Commons,
Attribution 4.0 International License.