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.
@@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
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.
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.
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.
@@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.
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.
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.
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.
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.
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.
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 >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
@@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.
@@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.
@@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.
@@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.
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.
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.
@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
@@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.
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!
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.
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
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" } } } ```
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.
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.
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.
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.
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.
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.
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.
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!
@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.
@@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
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.
%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 ..
@@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.
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.
'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.
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.
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
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.
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.
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
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.
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.
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
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.
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.
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.
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/"
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.
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
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.
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
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!!!!)
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.
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...
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.
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.
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.
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!
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.