Тёмный

THE TRUE POWER OF VIM - Saving hours of time with some vim magic 

Mental Outlaw
Подписаться 661 тыс.
Просмотров 135 тыс.
50% 1

Опубликовано:

 

9 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 463   
@linusbrendel
@linusbrendel 3 года назад
Honestly, I would've just written a simple python script.
@anant6778
@anant6778 3 года назад
My thoughts precisely. Just because vim can dont mean vim should
@alexandermartens192
@alexandermartens192 3 года назад
same
@someaccount3438
@someaccount3438 3 года назад
Was about to comment this. A python script would've been way easier to write than doing this and you would be done faster with it.
@chiragsingla.
@chiragsingla. 3 года назад
and in which editor you would have written the python script
@yark618
@yark618 3 года назад
And it would be exportable
@basedcon1262
@basedcon1262 2 года назад
The power of vim is really in the fact that it will always be there. When accessing nodes remotely, such as in the use of a cluster, it's better to just not worry about whether your favorite editor is available or not. For example, in my research I need to access a large cluster to run simulations. While I could just route the gui to me to use an ide, or use another text editor, it's just faster to use vim. Of course, in all my other, local work I will typically use an editor or ide that suites the particular language/situation. This video is well in line with what we should expect from Kenny, as he always advocates low level, close to the hardware, understanding. His solution may not be "optimal," but the fact it only relies on default software is the key here.
@mementomori8991
@mementomori8991 4 года назад
The holy trinity of Linux: Mental Outlaw, Luke Smith, DistroTube. Keep doing more videos, brother.
@tharushasarange
@tharushasarange 4 года назад
I think you missed Brodie Robertson.
@ΛάμψιςἈταξία
@ΛάμψιςἈταξία 4 года назад
Wolfgang is alright too
@bogicvujadinovic772
@bogicvujadinovic772 4 года назад
Chris Titus?
@bogicvujadinovic772
@bogicvujadinovic772 4 года назад
@@alan_core Yeah maybe, but still in some way he gives you a homework on what you should learn, especially this is helpful for me because I am begginer. But I agree overall, he is clickbaiting a lot
@bogicvujadinovic772
@bogicvujadinovic772 4 года назад
@Andrew So am I(I am learning vim dont worry)
@crysist13
@crysist13 3 года назад
This is the hands down best car on the market because you can open all doors at the same time by turning the steering wheel to the right, lowering your chair and bring it back up, turning AC fan to 75%, then down to 50%, then back to off, turning the steering wheel to the left, and double honking. Try see if any other car can do that faster.
@leonader9465
@leonader9465 2 года назад
Makes a lot of sense when the alternative would be opening all 1000 doors one after the other.
@KookoCraft
@KookoCraft 2 года назад
said truly like an inferior text editor user
@troglodyte1052
@troglodyte1052 5 месяцев назад
So true lol I use vim daily, but I would never recommend it to normies. It's stellar at performing bulk regex-based edits on files with idiosyncratic syntax, and it's perfectly fine at everything else. Most people don't need to do that, ever. Even for a lot of programmers, I can see how VScode is better in most cases. Vim has fully replaced it for me, but if you don't need to learn vim then suit yourself.
@Scroogs
@Scroogs 4 года назад
>he uses nordvpn Oh no no
@kris10an64
@kris10an64 3 года назад
Whats bad about Nord
@potatoeater5987
@potatoeater5987 3 года назад
everything
@kris10an64
@kris10an64 3 года назад
@@potatoeater5987 like...? Just curious, don't use the service myself
@potatoeater5987
@potatoeater5987 3 года назад
@@kris10an64 not a great history in terms of privacy, closed source, the settings app isn't great and it is moderately expensive
@zashbot
@zashbot 3 года назад
@@kris10an64 up until recently you could seed torrents with it but they removed port forwarding so rip
@MentalOutlaw
@MentalOutlaw 4 года назад
2 videos in 1 day, you gotta love that!
@Peshyy
@Peshyy 4 года назад
It's a blessing! Thank you
@wallabra
@wallabra 3 года назад
Mm yes, I love the scent of plain elitism in the morning.
@Spartan322
@Spartan322 3 года назад
Gotta agree with the other guys here, there is no reason to make vim, or to expect another text editor, to do this, it would've been just as easy (probably even easier tbh because I could just hardcode it without marcos) to script this behavior. This is peak over-engineering a problem tbh.
@anant6778
@anant6778 3 года назад
Say with me : "Vim is bloat " Everybody gangsta with VIM till me and the `echo "SRC_CODE" > file.c` boys pull up.
@Jupiter__001_
@Jupiter__001_ 3 года назад
Or just use regex or something
@kirayoshikage4057
@kirayoshikage4057 3 года назад
>over-engineering >using fully-featured programming language to do what a basic text editor can
@Spartan322
@Spartan322 3 года назад
@@kirayoshikage4057 bash and batch aren't fully featured programming languages, and vim is not a basic text editor.
@tarazed84
@tarazed84 2 года назад
@@kirayoshikage4057 Gotta agree, doing this stuff with a vim macro is plenty times faster than writing a script for it. If it gets more complex of course, a script will be more useful.
@raghunandan8162
@raghunandan8162 4 года назад
Longest Nord VPN ad ever. Just kidding , great vid!
@Ozzah
@Ozzah 3 года назад
First of all, you can do this pretty easily in other editors with regex, as many others have pointed out. Secondly, you can do this easier and quicker using sed and awk, as many others have pointed out. Third, you are leaving the scope of a text editor and are ankle deep in the area where scripting is far more applicable. You could have done this much quicker, easier, and faster from an interactive python environment.
@tarazed84
@tarazed84 2 года назад
That sounds interesting, I'd love to see a video about this. For many things vim macros are really powerful and easy to use, but everything has its limits.
@adammontgomery7980
@adammontgomery7980 2 года назад
Quicker and easier using other tools, only if you know them AND they are available.
@zojaXII
@zojaXII 2 года назад
python is bloat smh
@KookoCraft
@KookoCraft 2 года назад
python is trash tho :/
@wouldbabyhitlerkillyou4217
@wouldbabyhitlerkillyou4217 2 года назад
I agree with sed and awk, but python is garbage.
@joshuarose20
@joshuarose20 Год назад
Vim isn't just a text editor, it's a way of life.
@UCSAmitSinghBisht
@UCSAmitSinghBisht 3 года назад
Either learn coding or text editing choice is yours😂😂😂
@shaytal100
@shaytal100 4 года назад
I tested this on my machine (ryzen 3 2200G@3.5GHz) with lazyredraw and it took 1 second with neovim. And with nolazydraw it took about 5 seconds.
@SoulSukkur
@SoulSukkur 3 года назад
i have a low-end laptop but I was able to make it through instantly because I used regex-replace instead of macros. work smarter, not harder.
@anant6778
@anant6778 3 года назад
@@SoulSukkur Precisely ! *Happy Ken Thompson, Dennis Ritchie and Brian Kernighan noises*
@brakszysz
@brakszysz 4 года назад
This video is an anti-advertisement to anyone somewhat competent with a modernish text editor (Sublime, VS Code, Atom, etc.). This all can be done a lot quicker with much fewer keystrokes using such basic feature as multiple selection.
@julianavar3836
@julianavar3836 4 года назад
i was thinking the same but, having a cursor that is ~300 lines starts crushing memory
@eritert
@eritert 4 года назад
Vim can have multiple selection as well, this shows that something vim has that gui editors doesn’t was able to perform a large processing task that people normally do manually.
@clockworkpc
@clockworkpc 4 года назад
Bullshit. I used Atom for four years and switched over to Vim about a month ago. If you're on a computer that has a huge amount of RAM, you can use a memory hog like Intellij, but that's besides the point. In Vim you can do it efficiently, and you can actually do something like that on a low-spec machine.
@s4ecki
@s4ecki 4 года назад
@@clockworkpc You can do all that stuff with basic regex in any half decent editor, you don't need intellij,
@clockworkpc
@clockworkpc 4 года назад
@@s4ecki Get back to me when you learn to read English.
@latezksi
@latezksi 3 года назад
I just watched a dude spend 10mins typing tons of esoteric commands in some old ass command line tool to achieve the most basic shit you could do with np++ in half the time with half as many hoops to jump through. This video convinced me to not bother learning vim
@Winnetou17
@Winnetou17 3 года назад
I call bullshit, until you show how it can be done in np++ (which I assume is Notepad++?)
@latezksi
@latezksi 3 года назад
@@Winnetou17 >Type a 1-liner python script to filter the vpns by country >Run it (by clicking it in the gui like people living in this century do) >Open the filtered vpn list in np++ >Use multiple line select to efficiently copy paste shit in the right places >Gone and done
@Winnetou17
@Winnetou17 3 года назад
@@latezksi Sorry if I appear very stupid... how do you do the part >Use multiple line select to efficiently copy and paste The best I can think of would be to have the resulting JSON to be split per line, as many lines as the source, instead of it being a single line. Then you can select the source and paste as a column in the output, three time. Then join the lines back. I guess that's pretty quick, just as fast as Mental Health's solution.
@skaruts
@skaruts 3 года назад
@@Winnetou17 I don't know about np++, but I suppose it's something similar to what you can do in Sublime, where you can have multiple cursors and just edit/copy/paste text as normal. So you can copy N strings from N source cursors, and then paste them into N destination cursors. In the case of the video stuff, selecting all the "fr371" in Sublime would be a simple Ctrl-F search followed by Alt-Enter. That would give you all those cursors/selections ready to paste text in, regardless of where they are in the text. This would just take a few seconds to do. This is assuming the "fr" strings are the same amount as the "de" strings, though. If not, then you'd have to see how many selections the search for "fr371" gave you (in the info bar at the bottom), and select only that many "de" strings to copy/paste over. That would be only a slight delay. You can also do macros in Sublime, btw. I don't know about np++, though.
@GergiH
@GergiH 3 года назад
@@skaruts This. Simply multi-cursor and Ctrl+H (replace). Nothing else needed. I guess I won't ever get why anyone would say Vim is better for productivity when you have to memorize countless command possibilities, while any other modern editor can do the same things with 1 or 2 shortcuts.
@Maldito011316
@Maldito011316 4 года назад
That's actually quite easy to do with multicursors.
@bendover4728
@bendover4728 4 года назад
295 multi-cursors... good luck on that!
@Maldito011316
@Maldito011316 4 года назад
@@bendover4728 That's actually not a problem. I don't know exactly the limit on my machine, but I've done 2000 with painful lag.
@qwerasdfhjkio
@qwerasdfhjkio 3 года назад
you don't even need multi cursor ..., you can just search and replace??
@hexa3389
@hexa3389 3 года назад
The 1st half yes. The second part not so much.
@Maldito011316
@Maldito011316 3 года назад
@@hexa3389 Same thing. Put a cursor in each line (select the newline and find all occurrences) and start typing. CTRL+Arrows allows you to navigate between words of different sizes, and the End and Home keys also help. And you get to preview of how it's turning out before you delete the newlines. I love vim. I only got to learn it last year. But I've been doing stuff like this using multicursors for years before that no problem.
@almosthelpless9374
@almosthelpless9374 3 года назад
I really like Vim and I've never experimented with macros. It's great for laptops since you don't have to deal with a finicky trackpad. It's the same reason I prefer standalone window managers.
@stefanalecu9532
@stefanalecu9532 4 года назад
>literally any text editor Lowkey some vim elitism right here
@williamward9248
@williamward9248 4 года назад
Vim is the only text editor that uses a programming language to interact with it, instead of hotkeys, so it's more powerful. A better comparison to vim is something like AWK instead of a text editor.
@TehGettinq
@TehGettinq 4 года назад
@henry stevens its not a text editor. Its a bunch of tools that include a text editor. Emacs evil mode (with vim keybindings) looks awesome but i will stick with neovim
@skaruts
@skaruts 3 года назад
@@knightsofni0 What he's doing there doesn't seem as hard to do in Sublime as it seems in his video. It's a simple task with multi-cursors, really. It would probably take less than half a minute. Sublime can also do macros, but I have no experience with that, so I don't know how they compare.
@seanld444
@seanld444 3 года назад
@LastName Almaember I'm offended this slipped past his mind lol
@fraser21
@fraser21 3 года назад
I really want to love vim, but feel like a quick python script would do it just as well with a lot less archaic commands to memorize. Still, great vid!
@vaisakhkm783
@vaisakhkm783 2 года назад
If things like replacing things globally, you could simply use "visual block mode" That is really easy...
@aqualili
@aqualili 2 года назад
>quick >python try again
@winah
@winah 2 года назад
@@aqualili oook anon
@raminsadeghnasab9310
@raminsadeghnasab9310 4 года назад
IMO it's better to use a simple script written in python or any other programming language to do this. It will be much much faster than this. BTW, in case of vim macros, this is a great video.
@KookoCraft
@KookoCraft 2 года назад
python bad tho...
@Rugg-qk4pl
@Rugg-qk4pl 2 года назад
@@KookoCraft simple crap like this is the perfect use case for python
@justbreathegorge
@justbreathegorge 2 года назад
@@KookoCraft true
@Gokuroro
@Gokuroro 3 года назад
If this is basically a JSON object, you have a terminal tool exactly for that: ``` ls de* | sed -e 's/\.tcp\.ovpn$//' | jq -Rn '[ inputs | { ("+" + .): {"name": ., "fallback": {"host": .} }} ] | add ' ``` Notice I just added the places for replacing (and since you have the rest of the JSON, pasting it would be a breeze and just replace the places you want with ".". Quick explanation in order: - list all files starting with de (done in the video) - replace .tcp.ovpn with nothing (remove) from their names (done in the video from vim) - read the raw data (-R) into jq and treat the initial data as null (-n) - create an array with all the inputs, having each input (file name) be the key for an object concatenated with + ("+" + .), with the input being also the value for field "name" and field "host" (inside "fallback"), finish by adding all the objects in the array as part of a single object
@Gokuroro
@Gokuroro 3 года назад
I added a "head" to the command to show the result with only the first 2 items for simplicity: ``` $ ls de* | sed -e 's/\.tcp\.ovpn$//' |head -n 2 | jq -Rn '[ inputs | { ("+" + .): {"name": ., "fallback": {"host": .} }} ] | add ' { "+de100.nordvpn.com": { "name": "de100.nordvpn.com", "fallback": { "host": "de100.nordvpn.com" } }, "+de101.nordvpn.com": { "name": "de101.nordvpn.com", "fallback": { "host": "de101.nordvpn.com" } } } ```
@philippheller9439
@philippheller9439 3 года назад
I love Vim, but I think this task could've easily been completed in an editor like Notepad++ using regex find and replace in about the same time. Still a great video.
@CjqNslXUcM
@CjqNslXUcM 2 года назад
How do you replace with different strings from a list in Notepad++?
@tigergold5990
@tigergold5990 2 года назад
@@CjqNslXUcM find: ^(.+)$ replace with: json with the original line as \1
@KookoCraft
@KookoCraft 2 года назад
Notepad++ doesnt exist on Linux
@frantiseknavrkal2958
@frantiseknavrkal2958 2 года назад
@@KookoCraft Well, yes, but actually no: notepadqq.com/
@martysh1226
@martysh1226 2 года назад
@@KookoCraft wine
@danielrdrigues
@danielrdrigues 3 года назад
lol, wtf? I can do it on notepad++, it's just a regex replace, or am I missing something?
@TilemachosSheva
@TilemachosSheva 3 года назад
Yeah VIM people think these features are exclusive to VIM when almost every feature already exists in other editors and probably is easier to configure too.
@SoulSukkur
@SoulSukkur 3 года назад
The worst part is he isn't using regex. He's doing it manually once, and making the computer do it manually another 294 times. Using regex, in Vim or anything else, a computer can do this near-instantly.
@danielrdrigues
@danielrdrigues 3 года назад
​@@SoulSukkur it's just a case of pure elitism, sad, he might think he's better at codding than anyone who use a text editor with GUI.
@szymoniak75
@szymoniak75 3 года назад
Agree. I've been using vim instead of vscode for last month because of how people say it's so good but honestly it's not better. It has some cool features but first of all: I spend too much time setting it up, second: you can just install vim mode in vscode and then there's no reason to use vim anymore.
@TilemachosSheva
@TilemachosSheva 3 года назад
@@szymoniak75 Everybody VIM gangsta until they discover VIM mode in other editors.
@zeppelin0110
@zeppelin0110 4 года назад
Challenge accepted! I will propose 2 ways you could do this with Sublime that are easier (and likely faster): 1) Use multiple cursors (mc) to delete the unnecessary stuff from the list of hostnames in the first file. Now open another 'window' (or 'column', as Sublime calls it). In window 2, chop up the other text into *separate lines*, where each line ends at the point the hostname needs to be inserted. Now create multiple cursors for ALL rows in window 1 and copy & paste each of these new 'sections' from window 2 into window 1 into the correct places. The only annoying part is that you will need to copy & paste the hostname 2 times. But that's not so hard. If you think this is a lot of work, then you don't know the many shortcuts available in non-modal editors! 2) This approach utilizes the super awesome 'NimbleText' utility, which has web version and freeware downloadable version for Windows. With NimbleText open (web or desktop), paste the list of cleaned up hostnames in the top pane. You can clean them up in Sublime or in NimbleText or wherever. In the middle pane, paste the tricky json that you will be finagling. Replace the tokens you will want replaced with '$ characters (just like in the video was done with 'VPN'). Collect your perfect output at the bottom pane. Personally, I think Vim is pretty neat, but I think the way it *forces* you to do many things is quite awkward and outdated. This particular use case is actually one where Vim shines really well, though I was surprised by how poor the performance was for this operation in the video, even with the intermediary drawing turned off. Imho, there is no perfect text editor, but Sublime, Vim, Emcas, and VSCode all kick ass at text editing in their own unique ways.
@yogpanjarale
@yogpanjarale 3 года назад
This example could be a simple python automation script
@sunburst8810
@sunburst8810 3 года назад
Except it's a vim tutorial not a python tutorial you shithead
@bloomerboi21
@bloomerboi21 3 года назад
@@sunburst8810 go back to your own country. Ogga booga malato
@tikoblocks3224
@tikoblocks3224 3 года назад
The internet
@someonerandom704
@someonerandom704 2 года назад
@@sunburst8810 the thing he's doing doesn't fit the usecase of a text editor though
@kuge5694
@kuge5694 4 года назад
I'm learning vim. But honestly, I'd just use vscode with the vim entension. I only use vim when I'm on a server and just want to quickly make some changes to a file. I just don't want to spend hours configuring vim just to have the features vscode has natively. For example in vscode you can ctrl+E to search and open a file in the project directory by name. With ctrl+shift+F you can search for text in the entire project directory. Plus there are so many extensions & code snippets for vscode that you can download in one click. It's hard to justify spending the time to configure vim.
@szymoniak75
@szymoniak75 3 года назад
Agree
@Gornius
@Gornius 2 года назад
This is exactly what I use and I get best of both worlds honestly.
@zeitlose.klassiker
@zeitlose.klassiker 2 года назад
Problem is that the vscode vim emulation is a little crappy sometimes. Also no macro functionality
@FunOrange42
@FunOrange42 2 года назад
@@zeitlose.klassiker there are though? I use macros all the time
@wouldbabyhitlerkillyou4217
@wouldbabyhitlerkillyou4217 2 года назад
VS code has great features an ease of use, but poor performance though as it is an electron app (literally is its own web browser). Great if you've got at least like 16gb+ ram, otherwise you're really gonna want something more lightweight like Sublime or even a terminal editor.
@W_0_W
@W_0_W 3 года назад
I usually write scripts for such tasks on lua or node, which definitely works faster than vim and can be reused in future.
@anant6778
@anant6778 3 года назад
Not to mentions awk, grep , regex (which is old enough to have been an original UNIX thing ) .... gosh !
@sofortaufsklo
@sofortaufsklo 4 года назад
Screenkey and a little zoom would have been nice, anyway, thanks for the video.
@JuanGabrielOyolaCardona
@JuanGabrielOyolaCardona 3 года назад
Exactly.
@ezequiel5260
@ezequiel5260 3 года назад
So I watched this and thought this was moronic. I opened up my editor and wrote a very simple python script which replaced entries on a json with a list of words. Took me 10 seconds to write it, 3 seconds after executing it I had the desired output on a file. Still, I was curious about using a vim macro, I tried a similar macro to the one on your video, which I played 500 times, and it took a few seconds, no idea why yours was SO slow. I'm running a pretty modern CPU with fairly quick ram, maybe that had something to do with it?. Now that I found out using vim macros is not slow as I thought it was, I see the benefit of it, I might use them more often for more complicated edits. Thanks!
@ezequiel5260
@ezequiel5260 3 года назад
@championchap Yes, i was using Vscode for that and while there is macro support it's through plugins which are somewhat clunky or require prior config, which discouraged me to use them. Sublime does support them better, but I don't have that editor installed, nor I know how to use it. Vim already was on my PC as default CLI editor and I somewhat can manage to handle it.
@droodguy
@droodguy 3 года назад
@@ezequiel5260 Don't sweat it, people who use vim are stuck in the past and refuse to modernize. It creates some pretty vitriolic elitism, like tends to happen with any baseless fanaticism If you need to edit remotely, sshfs user@host:folder mountpoint
@TheRossiale
@TheRossiale 3 года назад
You can do this in sublime text in like 5 seconds
@iskamag
@iskamag 2 года назад
Can you show me then?
@TheRossiale
@TheRossiale 2 года назад
@@iskamag how
@iskamag
@iskamag 2 года назад
@@TheRossiale idk, since you told me you can do it I thought you knew how to
@TheRossiale
@TheRossiale 2 года назад
@@iskamagdont know how to show it
@iskamag
@iskamag 2 года назад
@@TheRossiale record it on obs and post on your channel
@pmester228
@pmester228 3 года назад
Zis issue calls for a shell script. A really simple shell script. Literally, just iterate over the server list, make an echo command with the text, and replace every 'VPN' with $i (i standing for the variable we iterate with) and echo it into the file with '>>', that should append it to the end.
@MartinsTalbergs
@MartinsTalbergs 4 года назад
%s/// .. “s” and “/“ comes from sed’s substitute command, % means “whole vims buffer” instead of % one can put any region: :’a,’bs/y/x (substitute y with x between two markers a and b) also :10,20s/y/x to apply substitution between lines 10 and 20 ... other sed commands also work .. i.e. :%d would delete all in buffer ..
@BarryArthur
@BarryArthur 4 года назад
The trailing `g` on `:s///g` means "globally within each line". The leading `%` in `:%s///` means globally across all lines in the buffer.
@grihabor
@grihabor Год назад
For this particular problem I would recommend just to look into jq, it's a really handy json tool which is designed exactly for this kind of tasks
@Raw5five
@Raw5five 3 года назад
I could do this just as fast in excel, no macros, no loops, just a couple formulas
@shaytal100
@shaytal100 4 года назад
I don't know any other "professional" text editor besides vim. But I always guessed they let you record macros as well. Don't they?
@MentalOutlaw
@MentalOutlaw 4 года назад
yes, subline text and otger editors have a macro feature, but it isn't as good as vims and is much slower
@MartinsTalbergs
@MartinsTalbergs 4 года назад
there is also “kakoune” - also modular editor
@krabos-k4e
@krabos-k4e 4 года назад
if you run on a toaster it's a bit slower on some of the other editors, if you run on a somewhat modern machine you see no difference
@liesdamnlies3372
@liesdamnlies3372 3 года назад
@@krabos-k4e The thing about vi and vim though is that they're everywhere. If I remote into any system, or am dealing with one in-person, that's in that giant family tree of Unix, I'll probably find one (vi) or both. If not, it's _tiny_ so a very fast download even on slow or unreliable connections (e.g. remote areas). Many of those systems may very well be "toasters", or intentionally very lightweight. Being able to use such a lightweight and fast editor is a very useful skill as soon as you have to start dealing with many different systems, and don't have the luxury of always using your own computer(s) for all your work (e.g. software engineers and programmers). It's another invaluable skill in one's toolkit, just like being super-fluent with Powershell if you're going to be dealing with a bunch of headless Windows servers.
@anant6778
@anant6778 3 года назад
@@MentalOutlaw Talking about slower, your slow-ass solution should meet regex/awk
@alex-cd1vq
@alex-cd1vq 3 года назад
Could I use Intellji? Or this challenge is valid only for that 90's editors?
@julienbongars4287
@julienbongars4287 3 года назад
I feel this could have been faster in awk... could be wrong though. Also, I think VSCode has a vimify extension which is pretty cool but usually I use VIM when I'm logging in remotely to a server of sorts. I've had friends who were forced to make vim their main text editor because of security policies where you can't download any files onto your computer. Think their still might be some plugins for VSCode that allow you to do this as well though. Never learned emacs but heard it was pretty good too.
@kirk0831
@kirk0831 4 года назад
Linux command line can do the job.
@Stone_624
@Stone_624 3 года назад
'Try doing this just as fast in any other editor' I could do this at least 5x faster in Sublime Text. 1) Instead of "VPN" for all 3 placeholder strings, use "VPN1", "VPN2", "VPN3". and copy/paste that 295 times (This might take a bit longer than with vim) 2) Highlight all 295 rows of servers 3) Press Control+Shift+L (On Mac) to create 295 Cursors. 4) Command X to yank all 295 server strings. 5) Command F and search "VPN1" , Click "Select All , which highlights all 295 Instances of VPN1 , And command V to replace all 295 instances of VPN1 with the 295 instances of Server Strings. This for me is usually instant unless there's 50,000+ lines. 6) Repeat for VPN2 and VPN 3 . Done. The time it takes for that macro to run in vim WAY outpaces the fallback of manually copy/pasting 295 instances of the JSON in sublime . Vim is my favorite text editor on linux, but for this kind of stuff the Multi-cursor support of sublime is way more efficient.
@christopherdixon4472
@christopherdixon4472 Год назад
As an atom user who just learned they discontinued my editor I now understand why people are so into VIM
@elEd0
@elEd0 3 года назад
I've done stuff like that in notepad++ and I can ensure you it does it in a couple of seconds without lagging the crap out
@mikenoel3823
@mikenoel3823 Год назад
To be fair, there is a very easy method to do this in Windows in roughly as much time as this VIM method: (i) cut/paste each of your VPN addresses into an excel sheet; (ii) cut/paste the desired formatted text into a word doc; (iii) use word's "mail merge" feature to input the VPN addresses into that formatted text as many times as you need; then (iv) copy that output into a notepad file.
@leonader9465
@leonader9465 2 года назад
This could probably be done just as good if not better with a script. But probably not with a text editor (other than VIM), so you're right on that.
@llortaton2834
@llortaton2834 3 года назад
1:39 Fallout Terminal Master Password flashbacks - PTSD kicks in
@bendover4728
@bendover4728 4 года назад
This would be even quicker in a simple bash oneliner: while read VPNSERVER; do echo "insert here the config line with required $VPNSERVER etc"; done < vpnservers_list.txt
@semmu93
@semmu93 3 года назад
in general, i really like your videos, but this was sadly very ignorant. most modern text editors can handle multiple cursors, so the process is really similar, and honestly, this type of text editing should be done using sed/awk/grep/etc. anyways.
@ArchitecturalAesthetics2046
@ArchitecturalAesthetics2046 3 года назад
Cool but why? A more sensible example would be to compare the time spent on typing a script that does this automation in vim vs a Gui text editor.
@syscruncher
@syscruncher 2 года назад
I have done similar stuff in Notepad++, but never tried a macro, though. I wish I had the time to take up the challenge just to see if I could do it…maybe I’ll try it later down the road just for fun. It makes me renew my desire to see notepad++ ported as a native Linux app.
@v0xl
@v0xl 3 года назад
sublime has "vintage mode"
@marsandbars
@marsandbars 3 года назад
I just multi-cursored every "it" in 1984 as plaintext, and it literally capped out at 500 Mb of memory usage in VSCodium.
@hemanthkotagiri8865
@hemanthkotagiri8865 3 года назад
"Because they all are inferior to Vim" - Greatest words ever said by mankind.
@synthesoul
@synthesoul 2 года назад
use case for vim: installing Arch Linux on a remote machine How to use vim: Step 1: ctrl + i, ROOT PERMISSIONS Step 2: Basic knowledge of how keyboards work Step 3: ctrl + alt + i Step 4: wq
@diegomora997
@diegomora997 Год назад
It's really cool to do that in vim, in my opinion you can process all this more efficient and faster with a simple script.
@ilostmypointer8695
@ilostmypointer8695 3 года назад
You dont need to use the mouse either with IntelliJ IDEs and it has a GUI to sooth my interal soyboy.
@lylez00
@lylez00 4 года назад
If you type :Ctrl-f and hit return, you can edit your command history. When satisfied with a line, just hit the carriage return and that will execute that line.
@CyberDruga
@CyberDruga 3 года назад
my tip for redrawing issues with vim and macros is using :normal 200@a, with this vim wont even bother redrawing until the command is finished. i don't know if this is faster than seting lazyredraw but for every one of my cases it was done in an instant.
@chillappreciator885
@chillappreciator885 2 года назад
Using Sublime with a file of urls: Replace All -> Regular expression -> find expression matches the whole string, replace expression contains the whole config string with group 1($1) in places where url is needed
@diablominero
@diablominero 2 года назад
I wouldn't use a text editor for this. I'd write a python script. It's as if you'd said, "look, my sledgehammer welds steel faster than yours does." Sledgehammers shouldn't weld, and text editors shouldn't be doing script-worthy tasks like this.
@IreshDissanayakaM
@IreshDissanayakaM Год назад
A Jinja template would come in handy as well.
@estring69
@estring69 2 года назад
Been using vim for about 12 years as my editor. Do a lot of text manipulation. Never use macros. You could run an ex script if this is something you have to do over and over again. Just a successive list of %s/^/something/ and %s/$/endsomthing/. I don't go to the trouble of saving different buffers, but that would probably be easier than macros. But yeah, the size of the ^ and $ are not a trivial size, so a python script with a template or r string would probably be easier than macros. I would think trying successfully to execute a vim macro might turn people away lol.
@RyanMcQuen
@RyanMcQuen Год назад
I learned Vim and used it for years. I understand its value. But I still prefer Sublime Text.
@rjmunt
@rjmunt 2 года назад
Vim is great. Sublime text is great. This example ... Not so great. As everyone says, script it in your favourite language ❤️
@UCSAmitSinghBisht
@UCSAmitSinghBisht 3 года назад
*used by grandpa's and they tried to inforce it to younger generation some took it while others used thier will and took the correct tool,
@lmnts556
@lmnts556 3 года назад
Sublime text AND Notepad++ can do all of this with find&replace + record macro then play multiple times. It is also a lot faster and simpler than vim lol. Dont get me wrong, vim is great and its great for remove controlling in a terminaly only env., but saying other text editors cant is simply just false.
@zashbot
@zashbot 3 года назад
Damn never knew vim was so powerful, I think i found a different way to do what you did here :)
@midimusicforever
@midimusicforever 2 года назад
Since you started out doing some of it on the command line, couldn't you have just done all of it with pipes instead?
@ivanjermakov
@ivanjermakov 3 года назад
4:30 your regex is not correct. dot (.) without escaping means "any character", so your pattern "/.tcp.ovpn/" will match not only ".tcp.ovpn", but also, for example "atcp#ovpn". To fix this excape your dots: "/\..tcp\.ovpn/"
@CTimmerman
@CTimmerman 3 года назад
Lol. Notepad++ and any editor with decent regex replace can apply the proxy JSON to the matching server part in less than a minute. Pasting X times is kinda neat but then you'd have to count, remember, and repeat that count, which are error prone like forgetting which mode you're in. I think some Vim users have that sunk cost / Stockholm thing going on.
@_modiX
@_modiX 2 года назад
hey Fallschirmjäger 😉 next timer I'd love to hear how these shortcuts work as you use them.
@setheheart4911
@setheheart4911 3 года назад
dude.. serious overkill. not trying to talk smack, but you can do this much easier other ways.
@Wix92
@Wix92 3 года назад
Pretty sure I could do this faster in any editor which supports regex search and replace.
@ujjal147
@ujjal147 4 года назад
Me, an ST user with Vintage mode on: maybe... Maybe I can do this kind of stuff. Vim user: uh, do you even have macros in Sublime Text? Me: IDK.
@Morfi333
@Morfi333 Год назад
I could do the same in fraction of that time in sublime. i just ensured myself there's no reason to move other than where you're forced to work with TUI
@franzlyonheart4362
@franzlyonheart4362 2 года назад
Can do this in awk / nawk. I'm old school Unix programmer from back in the day -- C programs and orchestrating Shell Scripts. I don't think I've ever properly used or coded anything in Linux myself, but from what I understand, it's more or less just a sub-type of Unix, perhaps one can call it a modernised version of Unix. So maybe I should check it out finally.
@notarandom7
@notarandom7 2 года назад
Tbh Micro is the inbetween. The Perfect Balance
@androkon6920
@androkon6920 3 года назад
Also, why didn't you just sed the file endings away? That's not a VIM-specific feature
4 года назад
The solution below was tested and it is almos instantaneous, amazing! Let me give you an example, maybe faster and easier than running a macro. And for this, I think it is faster and more difficult to achieve in any other text editor. Copy the template (the part of the code where you put "VPN" as a placeholder) to a register let's say 'a'. Visual Inner Paragraph "ayip -> register a yank inner paragraph. In order to change the default placeholder we can use sed Now on the VPN file just type: :%s/.*/\=substitute(@a, 'VPN', submatch(0), 'g')/g You have VPN as a place holder, so, you can use the content of each line "submatch(0)" to substitute on the register 'a' In order to avoid blank lines between each block you should copy the avoiding the To join all lines just type vipJ or vipgJ
@pskcalvo
@pskcalvo 3 года назад
Sorry to say this... but I just tried something similar with 1000 servers on Visual Studio Code and got it done in 1m32s (for the whole process). Maybe this was not the best example... I'm sure vim will be faster in some cases (probably a lot). But with lists under 1K lines almost any tool will do the job just fine. Again, I'm sure vim is superior, but if you are going to shoot out a statement like that you should use a better example (sorry) Of course, try to repeat the comparison with 500K servers and then... the "sed/awk" folks will kick both our asses :) By the way, I like your videos VERY much (not triying to troll at all!!!!)
@007hansen
@007hansen 3 года назад
Even Githubs MD editor would allow this. Just have to press [ALT Gr] + [LMB] 294 times for 294 multicursors.
@nyiyui
@nyiyui 3 года назад
I have tried this using Python and it was slow, but I did it in Go around the same time as yours. I guess it isn't technically a text editor though...
@bbseal6174
@bbseal6174 4 года назад
thought i clicked on a luke smith video
@JohnMassaglia
@JohnMassaglia Год назад
I've done macros like this in notepad++, but I prefer doing them in vim or with a script.
@ultrahalf
@ultrahalf 4 года назад
Learning vim is better than pressing Ctrl n Home row ftw
@stefanalecu9532
@stefanalecu9532 4 года назад
B-b-but muh evil mode
@ultrahalf
@ultrahalf 4 года назад
@@stefanalecu9532 vi vi vi
@chandanmaurya5568
@chandanmaurya5568 3 месяца назад
Maybe this video is intended as a parody. I also do this kind of edits in sublime text. In sublime this would not take me even 1/2 a minute to complete all the action in this video (Of course without explaining details). Just for info sublime and some editor (I know vs code) will not stress even for thousands of multiline editing. I am currently investing time to checkout neovim. Most likely there would be a better way to do it or else vim will not cutout if it requires rendering off for less than 500 lines edits. So maybe this video is a parody to mock vim.
@AHumanBeingNamedAlex
@AHumanBeingNamedAlex 2 года назад
I believe Notepad++ also has macros, haven’t tested yet Edit: started using Notepad++ Macros, they're amazing
@piazzalungaut
@piazzalungaut 4 года назад
why don't write a c program that takes care of that text editing?
@byakka
@byakka 4 года назад
Sick burn
@hobrin4242
@hobrin4242 4 месяца назад
I think with multi cursor edit you could type everything that is before, and after the subdomain
@viiltelijamurhaaja7225
@viiltelijamurhaaja7225 2 года назад
So vim is beat text editor? How do I make .txt file with it?
@ghostpants8172
@ghostpants8172 3 года назад
When it's true power is just a feature for other ide's
@muskyoxes
@muskyoxes 3 года назад
Best part of this vid is randomly blaming systemd for crashing
@ChucklesMcGee780
@ChucklesMcGee780 Год назад
bro that thumbnail killed me dead xD
@cubed.public
@cubed.public 6 месяцев назад
There are a lot of things I heard about vim, macros is definitely not one of them
@stevengill1736
@stevengill1736 2 года назад
First ad was for MS Edge again! Must be the YT ad placement algorhithm thinks I'm shopping for an OS, wow! Note to RU-vid: I'm not.... And thanks, looks like Vim is very useful for script files and all that. Back in the day I did a lot of graphics with POVray, etc, and editing the scriptfiles to create animations - this method would have speeded things up quite a bit. Cheers...
@michaelgrubb3508
@michaelgrubb3508 4 года назад
btw, if stdout is not a terminal device (e.g. when piping out to another program or redirecting to a file) ls will by default only output one entry per line.
@khmnc
@khmnc 2 года назад
tbh using macros would have never even occurred to me. i would have made a script that would read in the list of servers, sed them into a template string, and append that to the output file.
@michaelerwin8744
@michaelerwin8744 3 года назад
I'm on windows learning how to use VIM. Windows/Linux war refugees now nearing utopia with Windows 10 and WSL 2. Geek treaty finally ratified.
@someonerandom704
@someonerandom704 2 года назад
Desktop Linux is good enough now that I'm not going to use win 11
@EffToyz
@EffToyz 4 года назад
5:30 you could use s/// or just press . to repeat last edition.
@VioletJewel1729
@VioletJewel1729 3 года назад
or & or @: (then @@)
@night_fiend6
@night_fiend6 2 года назад
I am pretty sure that Kate can do this. What posts me off with Vim is the navigation. If I need to use a CLI editor I use nano. Because usually when in need a CLI text editor, I have somehow messed up my .Xorg configuration in some way.
@vyrwu
@vyrwu 3 года назад
Personally, I prefer to code, so I would solve this by writing a simple Node.JS app that translates the server names into proxy imports. Could be done in Vim tho!
@seanld444
@seanld444 3 года назад
Alright, I'm gonna be that guy, but only sorta. Emacs. More specifically: Spacemacs. Get the simplicity and modality of Vim with the extensibility and customizability of Emacs. Literally don't think I'll ever be able to find a better text editor. Not to mention the editing modes: SES, Org, Calc, Dired... it's the whole damn productivity suite lol. Sure, you could consider it bloated. But Spacemacs is one of the few cases where I love the bloat. In lightweight scenarios, NeoVim baby.
@JuanGabrielOyolaCardona
@JuanGabrielOyolaCardona 3 года назад
Same :)
Далее
How to Become a VIM /G/od
12:44
Просмотров 56 тыс.
Vim Tips You Probably Never Heard of
12:11
Просмотров 118 тыс.
Cute
00:16
Просмотров 2,5 млн
Feds Couldn't Crack Signal, So They Banned It
8:50
Просмотров 545 тыс.
Tech Subscriptions Are Out of Control
8:51
Просмотров 117 тыс.
TailsOS Guide For The Ultra Paranoid
35:32
Просмотров 428 тыс.
A Vid in which Vim Saves Me Hours & Hundreds of Clicks
10:23
OpenBSD Desktops Are For Hackers Only
13:14
Просмотров 200 тыс.
i tried Vim...
10:06
Просмотров 43 тыс.
When a friend recommends you Vim...
2:38
Просмотров 93 тыс.