How vim Makes my Daily Life Easier
ฝัง
- เผยแพร่เมื่อ 1 พ.ย. 2024
- >inb4 autistic nitpicking about how did everything
---
Email me: luke@lukesmith.xyz
Send me donations via PayPal at luke@lukesmith.xyz
See my website: lukesmith.xyz - วิทยาศาสตร์และเทคโนโลยี
I've been using vim for 15 years now. Mostly cause I can't find out how to exit the program...
@@matiasarancibia365 Yeah, and not even mine. But then again, it's funny because it's kinda true, right? The first time I ever used it I actually had to google how to exit it and angrily swore I'd never use this shit again :p
@@Ezechielpitau Too accurate, trying to learn it right now and it's rough but I know it will be worth it in the end
Ouch! I just chipped a tooth on your stale ass joke.
:qw if you want to save 15 years of work.
@Desmond Willowbrook
I've integrated a lot of tools into VIM over the years such as Perl Tidy and can't imagine switching to some bloatware.
I'd be slightly more embarrassed about Sabrina the teenage witch
Chris Ball Everyone loves Salem, everyone.
Say sike right now.
Great video, but faster way to remove sqare brackets using macro is:
qd0t[dt.jq
Which means:
1. qd - start recording macro d
2. 0 - move to begin of line
3. t[ - search forward for [ and don't include this symbol in search, which places cursor on space before it
4. dt. - Delete till (dot)
5. j - move to line below
6. q - stop macro recording ;)
This would work well for this specific example, but if you want to delete inside brackets in general then I liked that he showed how to do that.
Of course another way would be dq0f[d%xd%j0q
qd - start macro
f[ - find [
d% - delete to the matching close parenthesis
x - delete the space
d% - as above
j0 - down and back
q - stop
And there are still other ways. All of which are quick really, it's more a matter of what's more intuitive to you and what's burnt more into you're muscle memory.
@NK Why avoid macros? They're an extremely powerful feature of the editor and very easy to use. Among other things, I use them for refactoring code all the time.
youtube comments are the best teachers
In this example it would have been even faster to use :%s/\ [.*/\.mkv/g
late tip, but `+` is a shortcut for `j_` meaning you could save the 0
>daily life
>renaming chinese cartoons
neckbeard momeme
>using greentext on youtube
DAB
D - delete
A - around
B - bracket
\o7
Thank you. When I talk to Microsoft-cultured developers, (I am generalising here) so hard to make them understand command line is powerful, people don't understand that each GUI application invent their own version of 'find', 'grep', list, etc. Each app poorly does its own way, and mostly never get right, that why I love Linux culture, it doesn't make developer dumb and inefficient. I installed VIM plug in EVERY IDE, and constantly just go back to real VIM to do plug-in-unsupported stuff. Love the content you put here. I one time did a 'vim' ninja show to my whole team, people are shocked, but they just don't want to remember any short-cut than Ctrl-C Ctrl-V.
Ctrl c and v is all you need for Stack Overflow kek
(I realize this is a 4 year old comment)
windows has cmd which is fine for basic shit but seriously underpowered. every command is its own collection of wtfs and poor design choices. then there's powershell which is ridiculously verbose and enterprisey. I don't want to have to type an essay to download some files, thank you. there's winget which is Microsoft's poor attempt at a package manager for windows, and chocolatey which never seems to work right. and don't get me started on windows batch. if you need to do any development on windows you are much better off downloading perl for your dev setup stuff. or just installing wsl and disabling as much of stock windows as you can. i still don't understand why the start menu has to be connected to the internet or why we need some cortana thing in the taskbar. on any new windows installation those two are the first to go
2:35 uhhh CTRL+V as he actually said uhh that's so funny
wow, i actually write python scripts for that.
this vim thing just showed up in my recommended and only the algorithms can tell me why.
but i ll definitely look into that.
Yeah, in my comment I wrote a 1-liner for bash:
for f in $(ls); do n=$(echo "$f" | sed "s/\[CBM\]\_//g;s/\_/\ /g;s/.*Season/Episode/g;s/\ \[.*/.mkv/g"); mv "$f" "$n"; done
I know were both of you are coming from, but at the end of the day, Vim by itself is a very powerful tool. Yes, you can script the shit out of your needs, but I feel like doing this in vim provides far easier tools to quickly test / iterate. A quick undo and nothing happened immediately comes to mind when comparing to, say, a bash script.
oh yeah, before vim I used to write, I shit you not, _autohotkey_ scripts for this sort of thing. I'm on linux now and using vim, and that's much more flexible, especially with the wonders of :s, :norm, and, as a last resort, macros
I love it that you show a practical example to visualize how a real world operation looks like. :-) Great job on explaining the steps too.
i did this exact same task with a bash script when i first got into linux, I was so proud. It was a great learning experience but this method seems much faster and more versatile. Thanks
"I don't even know what this stuff is in brackets" (e.g. "[ACFADD3A]")
That's the CRC-32 of the file.
Every file has a checksum. You can compare their sum to the one in the filename and see if they match up. If they don't, the files are corrupted.
It's mostly for convenience. You could always look at the place you downloaded them from to get the correct checksums again. Or watch the video and realize halfway through that it's fucked up. Up to you, really.
weird flex but ok
thank you! now I know even less!
Great video! There's also dt. for "delete until .". This command remove all the text between your block cursor and the ".". You can use it for everything in Vim. So lt[ works too. Go to right until the bracket.
you have the best thumbnails out of any channel, congrats
Recently been binge watching your videos after seeing your distro video, promptly sold my old ideapad, got an X201 with archlinux, and have never been happier (and all the Mac normies in my university are jealous). Love your vids, keep up the good work!
I did the exact same thing. Soon we will all be arch-normies.
Do you watch them from afar and mutter under your breath about proprietary software? That's what I do when I'm not downloading hd anime girl wallpapers or updating arch
Basically yeah, kinda like Clint Eastwood "God damn idiots, apple users, ger off my desk"
Great video, so useful for someone nervous about moving from nano. Thanks Luke!
Holy fuck I thought vim and macros were complicated but you explained it so simply.
Shorter version:
:%s/^\D*/E
/
:%s/_/ /g
:%s/ \[.*\./.
/
Explanation:
1) On every line (:%), replace (s/) from the start of the line (^) all consecutive characters that aren't digits (\D*) with the letter "E".
2) On every line (:%), replace (s/) an underscore character with a space, globally on each line (/g).
3) On every line (:%), replace (s/) everything from the space before the first open bracket ( \[) up to and including the first period (.*\.) with just a period (.).
This would be teaching how to use regular expressions, not how to use vi, so that's kind of a different skill. But it's still useful to know.
oh that's smart! I never consider using uppercase groups like \D \W etc, I probably should. for the first thing, my instinct was :%s;.*\ze\d;Episode
which is basically what you do, but in a more complicated way. not even sure if it works like I think it would, would be wonderful to have the actual text there to play around with
This is exactly what I needed and I didn't even know that I needed it, or that it was possible.
I also download everything I watch, old school like that and I also rename episodes.
But, because I was doing it in bulk, I would just put S01E0 in the clipboard, then Ctrl+C and then add a number, then go to another season, change it to S02E0 and continue with Paste > Add Number > Enter > Down arrow > F2.
I was doing this in Windows, though.
Awesome! I'm definitely going to use a few of these tools in my workflow. Its good to note that, alternatively, you can also do this on the command line for all files in a folder using unix (and/or shell) commands.
>Video LITERALLY starts with talk about normies
REEEEEEEEEEEEEE
Romance of the Three Kingdoms, man of culture I see
Thanks. It took me less than 15 minutes to rename all of my videos. Thanks Luke c:
Cowboy Bebop?! Ya Weeb! (Just kidding, that's an amazing anime!)
Started using vim months ago I just can't quit
The right tool for the right job. If something to edit is very heterogenous, vim is the choice. If it is very homogenous and repetitive, I normally use awk, sed, grep or related. Sure you can use vim with scripting and macros but I find a nice one-liner better.
What the fuck are you even saying
wo man dich überall findet, du sack! jetzt erzähl mir noch warum das bei mir nich geht!
thanks for your input @Narwaro :)
Thanks for this cool video, now I’m not quite as afraid of macros as I used to be.
yeah same. this video shows macros just like some common normal thing.
otherwise, they always felt like some foreigh thing to me in any software.
but ONLY this video made is clear to me that it is just a recording of your steps
I'm hoping other people said that but those are CRC checks that you can use to ensure the files are complete and undamaged. Personally I keep them just so if later I'm transferring or anything looks funny I can check the files again. It's very traditional in Anime file names.
But dude that type of mass file renaming.. that's the stuff that made me love using command line. One day I hope to get back to it.
>animeme
e
So glad you used 'f' in your example. A great command a great reason why you should NOT use ',' as your mapleader! ( comma will repeat your 'f' search in the opposite direction)
Hey man I runned vim on my machine but I didn't managed to close it so I bought another pc.
relatable
vim has saved my life, I deal with a lot of texts and stuff, with other editors I couldn't keep up like nano, etc
great video
>neon genesis evangelion
Mein Neger
Also have you watched Bill Nye's new series, Bill Nye saves the world?
Its the best show ever made
Evangelion blows.
(I'm going to lose lots of subscribers for this comment.)
Yes you are
>200%_mad.jpg
Luke Smith I really don't care. Still love them green pepes.
Bill Nye, that one actor that calls himself a scientist? He's adorable.
whats a good open source program to rip dvds?
I'm actually surprised that Luke watches some Australian shows like CNNN, Yes We Canberra!, and Chaser's War On Everything. I wouldn't have thought those shows would make it overseas.
Here on Windows I use Bulk Rename Utility for this. It works well and the gui doesn't treat me like a child.
I was just thinking that, I use that as well and it's amazing.
i just get a error saying "No renaming to be done!" if i have a file selected. else i can rename the file the cursor is on. very frustrating.
2:36
>uhhhh
i literally JUST manually renamed every episode of Cowboy Bebop the other day because i didn't know this trick. glad i know it now tho
I would love a video about your linux setup
yesss plz!
+1
That's like the majority of his channel. In fact, you can actually completely replicate his setup with extreme ease, he has a boostrap script that does just that. Myself and more than 400 others have forked his build on GitHub as a starting point for our own systems.
@brooksman10 can you give us some more info? what os is he running? and with what mods? thanks in advance bro.
@@rev3ngous789 He has now two of those scripts.
In this video it is his Arch Linux setup with i3wm.
But now he uses Void Linux with dwm.
you can check it out on these websites:
lukesmith.xyz
larbs.xyz
MDE
smugpepe.jpg
He's worried about Cosmos and yet he has "Sabrina the teenage witch"
How do you make your file explorer to show the files under current cursor selection in a separate pane?
Its the default behaviour in ranger. Press '~' to toggle it.
Hey random question but what terminal font are you using in this video?
thanks for sharing your workflow!
How did you set up the system bar at the top? (showing the temps from lm_sensors, date time etc). Like it particularly for the vim-airline status bar like look.
There are so many times where I could've used that thank you so much
Some of the commands you type look fantastic. I mean something like "uhhh Ctrl+V" =)) And thank you very much for your detailed yet clear tutorials!
Yay Animaniacs! :D
BTW, pretty sure you don't have to escape the space character in regex substitutions.
Vim is an essential bit of kit for me too. And I'd wager I don't even use anywhere near half of what its capable of.
[ Emacs User Alert! ] The biggest problem with Vim keybindings that I could think of is that it really gets deep in your brain, and you'll not be able to effectively edit text on other software or platform without constantly reminding yourself NOT to use 'hjkl' to navigate or press 'i' and 'ESC' to hop in and out of Insert Mode. While with Emacs bindings all the navigating shortcuts are prefixed with Ctrl or Meta (Alt) and can be ported to different platforms once you get used to it!
Yea, relatable. Sometimes I get myself saving an office document with :w
I respect your taste in 90's cartoons. You would probably like the Sam & Max animated series, all the episodes are on YT.
How are you navigating through your files from terminal like this? It looks great! I would like to do like this. How can I?
It looks really nice, but seems too much work to learn.
Typically I think this same sort of stuff can usually be done with batch regex renaming. I guess one could say "there's more than one way to skin a cat", and I prefer that one to vim. Although vim is definitely intriguing
Really enjoyed the video. I've never seen ranger before, will definitely check it out.
One question. What OS are you running?
darude sandstorm
1:07 - 1:15 oh my goshhhh that's so great. i have thought abt smth like that many many times before
I love vim. Recently started using it in 2017. I would turn down any job that didn't let me use vim
hehe, nice
Hey man, thanks for the Video. Hey what is the tool you used to make those cool colorful sections on your top bar?
DUDE! Been using your i3 configs with larbs for several years but never realized this existed. it has made my life 100 times easier :)
I think I got my vimrc config from your stuff as well. I found the following vim map works well to strip all periods except the last one out of all file names in the bulk rename buffer : map F :%! rev \| sed 's/\./ /2g'\|rev
Could probably expand on that to include _ and any other chars as well.
great thumbnail as always. really enjoying your vids!
Thumbs up for Cowboy Bebop.
>IT Crowd
Awesome show. Glad you like it too! :D
You should do everything as fast as you can, show the video of that and then slow it down explaining what you did. That way people can see how fast Vim really is.
Maybe with a file that has intentional errors (e.g. spelling and punctuation) for the purposes of testing, simply open a copy in vim and another copy in a GUI editor like LibreOffice; proceed to find and correct the errors while running a timer...
@@edwinmoney619 i would like to see it too
what's wrong with watching Neil degrasse Tysons series? That's such a cool guy!
I agree, and I even liked the Cosmos »reboot«. It just can't quite match Sagan's co-writing and Vangelis' musical score.
crazymonkeyVII It's all about the "gender is a spectrum" meme. Because of that episode and some climate change stuff everyone thinks Bill Nye is "on the spectrum".
Is it really »all about the "gender is a spectrum" meme«, though? Maybe that’s just in your head, syth406.
i watched that last year just after watching the first series by sagan i honestly didnt noticed anything wrong. they are both great shows, very inspiring. the only difference i could see between the two shows was that the one by sagan looked like it was recorded on a potato!
Head over to www.reddit.com/r/NeilIsVerySmart to understand why people hate neil
As an undergraduate from ZZU and graduate is US, I feel compulsive to say hi to you. And I like your video a lot since I am also a big fun of vim.
"Romance of the Three Kingdoms"
Is that the one that came out recently, like within this decade? Huge fan of that one.
It's the one from the 90's that the Chinese government made. I used to watch it a lot when learning Chinese. I don't know of any more recent ones!
#vimmasterrace =)
Could you do a video on Terminal IDE? It's a sweet terminal editor for android
JOOOOOOOJOOO tuturutututututututuru
What's the default binding for bulk renaming, is it a feature in default ranger? I can't seem to find the feature. Pls help
Hi Luke. Is there any possibility to use highlight line under cursor in vim through multiple split windows? For example, I'm visually comparing line by line 3 places in code, use 3 vertical split windows. It would be good to highlight whole line across all splits.
Woah...what's with all the Australian TV shows? I didn't know anyone outside of Australia watched the Chaser's War on Everything!
How does he turn on screenkey here? is it the run command palette that you produce with Alt+F2 normally on gnome? 1:54
I can't help but notice that your battery is on 891% WTF
In case anyone is interested in removing the brackets (including the containing text) using "find and replace". This would be the string:
:%s/\ \[.*\././e
Or record a macro as following:
0f[dt.x
(Goto the beginning of the line [0] and [f]ind the first [, then [d]elete [t]ill the [.] and remove [x] the empty space)
0t[dt.
No need for "x" ;)
You're right sir! ٩(◕‿◕。)۶
Great videos.I'm just getting started with Linux and you're helping alot.
Recently discovered your channel, I found gold!
Awesome video, vim is fantastic (I need to learn it). Thanks!
very interesting to watch someone else's "way" - learned a lot despite having over 30 years of using vi. I typically use a lot more %s, like you did for once - eg I'd follow that up with :%s/\[[^]]*\]//g or something like that. I find this helps master the expressions, which is a skill also useful in other places, like with sed.
I'll definitely be trying out visual mode when I next open vim - I usually only get into it by accident.
Call me a noob, but I like Kate. I tried to get into Vim, but it's just too unintuitive.
is there a way to add the title, artist/showname, and other Metadata from the filename directly to the exif or metatag info?
that was fucking BEAUTIFUL dude
I think I just found my new favorite youtuber
2:37 uhhh
I'm in no way denying vim effectivness in code writing and editing, but what you did here, can be done in couple of minutes in Total commander Mass rename tool. Yes, couple of minutes is longer then probably around one minute if you proficient with VIM commands enough to enter all this command fast. But do you really rename bunch of files every day? Like downloading 9.5 hours of tv show every day and rename it for storage purposes? I don't think so. If you use VIM every day, then yes, no need to learn new trick, but unless you are renaming 1000 files every day, general file managers can do work just fine. BTW, Total commander can remove all text inside [ ] easily using mask [*] no need for macro.
You can delete by mask(regex?) in vim also. The point is you can use vim for editing config files, looking for logs, programming, etc. It's not just for renaming files. It's incredibly powerful when you're working on remote systems, where X is not installed. After few years of using vim, I can't imagine working without it.
would have been great to have a link to this "ranger" plugin...
google gives me many different sources on github.......
I mean.... my big question about "time saving" techniques is whether they actually save time. Like I legit would have to spend 30+ minutes installing certain packages to extend vim, and learning the shortcuts, and then I have to watch this 8-minute video and then maybe it works well? You'd really need to be doing stuff like this all the time to actually save time.
but that's just the start of what you can do with vim. So yeah there's a frontload of time investment to learn it but the point I think is that it makes a lot of your day to day computer interactions faster. I rename files all the time to the point where I've been considering teaching myself how to write batch scripts the way I taught myself to write a batch to turn off stupid windows defaults (I just double click a file and now computers show file extensions without me having to dig up File Explorer Options). If you spend a lot of time in text files or renaming files this could be the sort of thing to motivate you to spend that day or two learning and setting up Vim.
“You’d really need to be doing stuff like this all the time to actually save time”
Exactly
But how much time did you save watching this video and typing this comment?
Thank you so much!
Came for the frogs, stayed for the tutorial.
Luke, any suggestions about using vim for note taking on the lectures? I heard about markdown plugin for vim but I wonder whats your approach?
4 years later... im not advanced, but i would blindly recomend emacs orgmode, nexcloud notes or joplin cli. Im a joplin begginer btw
1:42 nice taskbar, amh, what OS/DE/software etc is that? 😅
Veni,vidi,ViM. Salutations from France.
Q:
How dose it work without **Ranger**?
Maby: twice the lines. Editiging it and make a Makro like [ :!mv old-firstline new-secondline ]???
Or maby in :Ex ⁉
Is there a better way to do it? An efficient one???
Greatings
Sven Windpassinger
Spaces in filenames? Seriously?
0:57 can it be used to create new files? like you entered a new line, and it will create a new file?
Dateline "I'm Chris Hansen...why don't you go ahead and take a seat"
Ranger is a realy nice cli file manager
I am an abnormal person
Yay
>bill nye the science guy
will give you props for twin peaks though
In fact you don't have to escape the space. :-)
EDIT: Instead of da[ you could have just used d% to "delete up to matching bracket" :-)
I use vim at work. Some of this stuff here is incredible though.