You can also use most, if not all, of the existing GUI-based editors and IDEs without touching the mouse: most of them support a large, powerful and configurable set of keyboard shortcuts (that I do not use...).
@@woouinluigh Well unless you have a bluetooth keyboard paired with a tablet or smartphone. Which I've used with tmux / vim a great deal. Actually Mosh + iOS Blink works very well with an unstable cellular connection while on a train. Mosh replaces SSH and provides a much more responsive feel on poor connections. mosh.org simple roaming with session state sync with extremely low latency and local echo so you are not waiting on SSH to catch up.
@@peterjansen4826 Graphical text editors and ide's have been feature equal with Vim and Emacs for decades. There's no feature reason to use Vim over Sublime, Atom, Geany or Kwrite.
@@radioactivebob1 You're not required to use 100/100 of vim key bindings and commands. You're still be more productive with the basics than nothing. + Taking some time to learn something that will save you time/gives you advantages afterward is an investment, that's what you've probably done when switching from windows/macOs to GNU/Linux or from a DE to a minimal tiling windows manager
11:22 At that point you can just hit I" and that will do the job. Similarly, to add to the end of each line select in block visual mode, then hit $ and A". No need for all that command mode then normal mode trickery.
Of all the examples that were given, I’d either never use it, or I can do it faster in sublime. I used Vim for 6 months and I still went back to Sublime. I think it just comes down to personal workflow preference
I think a mix of vim and Sublime could actually be a very good workflow. I do that with VSCode and I know there's a vim extension for Sublime. Why don't you give it a try
That's what I was going to say. Each time someone gives me an example supposed to show me Vim's superiority, I can come up with a simpler way to do the same thing in Sublime without having to memorize tons of keybindings and switch mode a bunch of times, and often it happens to be faster.
How have I been using Vim keybindings for almost 2 years and i didn't know about :ab that would have been beyond useful many times. Amazing video DT keep up the amazing content.
I use just vim, but everytime I see someone speaking of advantages of vim, clearly they haven't spend a second loooking up the documentation of other editors. Every code editor has a lot of features like those of vim.
I mean not really. I use neovim on a daily basis as part of my school classes. I've run macros more times than I can count and features like that are simply unavailable in other editors. Sure there are extensions to do stuff like that but then the other editors are already so painfully slow in starting up
@@tanmaydeshpande Yeah, I mean, "a lot" of features, not all. Like, all (or most of) the stuff showed in this video can easily be done in vscode or sublime. But, for example, the integration between vim and the shell is something unique. Vim is awesome for a lot of reasons, but not because you can jump to a line or delete 3 words with a few keystrokes.
@@rogerpenrose1368 eh I think vim is powerful for that as well. Like in normal editors, you can scroll using the mouse or the pgup or pgdn buttons. In vim you don't need to touch anything apart from your home row for navigation. Simply press number+j or k and you jump so many lines at once. And with relative numbering it's even more easy to do stuff like that
Honestly the IDE's I'm using are all capable of selecting multiple rows, replacing words and swapping lines. If you're comparing Windows Editor to vim, it's obviously more capable of doing stuff. Haven't yet found a feature convincing me to learn vim.
I mainly just like vim's keybinds, they're quick and easy to access. Often you have the same editing power in your IDE of choice with vim bindings as in vim itself (some extensions even use vim as a backend).
You can define more robust keybind and commands with vim than any other editor. IDEs are only more useful when you're using their features like debugging with realtime memory information graphs. If you're just editing code then there's literally no reason to use an IDE.
A few notes: - `g;` goes back to the last modification, while `` would be the last cursor position - to indent a paragraph, you can use `>ap` (`ap` is the paragraph text object) - to remove the `"` in this context : `vap :s/"//g` (select around paragraph then replace '"' with nothing, `g` to get every match in the line) Good work though, looking forward for more Vim vids !
Clouldn't agree more. Just discovered diff-mode editing, visual-block editing, macros, built-in functions like strchars() and getline() in custom mappings and the power of "very" magic regular expressions during the recent decade. For example, removing/adding those quote marks would be one thing I'd use regexp's for, rather than macros.
I feel so comfortable using Vim and I realized that I know only 0.01% of its features. To delete ending " instead of macros I prefer %s/"$//g, and I instead of doing "norm" in block mode I use "I", or "A" directly, I don't know if what I do works in all cases. Great vid!
That's why I don't understand why guys spend all this time learning Vim when they're never going to use most of it's features. It obvious most are just following the heard and doing what's cool. It's like the sudden popularity of tiling widow managers, it's a fad that will fade.
@@phillipmartin3910 Vim will be 30 years old this year, and vi goes back to the 70s. That's a pretty long fad. I've been using it as my main editor now for 6 years.
@@umka7536 Ah yes. I so hate when VS Code makes me press End to move all my cursors to the end of the line. Typing in %s/"$//g is so much faster and makes so much more sense.
I will probably end up learning vim anyway, but I find it a bit discoursging how almost everytime someone comes telling how vim is so superior to other programs and it will save you thousands of hours they end up giving some examples that could essily be done in typical programs just as fast, like the example about deleting the double quotes, I could do that in a couple seconds in any editor with multicursor, faster than using a macro. They are just as ignorant about standard editors as we are about Vim.
After so many years using vim I don't know how but I am still learning new stuffs, amazing. I didn't know about abbreviations. Thank you for the content DT! Keep going!!
Vs code can do cutting/pasting lines, moving lines up/down, navigating to the end/beginning of the document, selecting multiple lines at once, and regex search/replace. All without the mouse... I knew VIM had a hardcore following. It's good to know I'm not missing out with these specific examples of why it's so powerful.
He didn't seem to touch on text objects, which is a very powerful vim feature. The power of vim is also in its ubiquity; its gonna be there on any machine you ssh into and any container you enter into. VScode is excellent but I think the main advantages it has over pure vim is the built in debugger and some of the refactoring tools. You can pimp out vim to do pretty much everything vscode does, but the lack of the debugger is an issue
Sorry man but that's not the case . He's just showing a few percentage of vim capabilities on this video, he would need 10 hours to show what you can do with vim. It's not still one of the most popular text editor along devs ( 25/100 according to SO ) for nothing even in the GUI age. With coc.nvim we don't even need vscode anymore.
@Henrique Borges True. Vim wasn't made for me. It was made for incredibly old and outdated operating systems, with weird and convoluted control schemes, and primitive input methods. As for me, i prefer efficiency and ease of use over stubborn nostalgia against all reason.
Hi ! A few more tips : Going back to the last cursor place - g; - but you can also browse your location stack with - C^O - (backward) and - C^I - (forward) Indent a whole paragraph (in your case here) : - >ip - (no need to count, and you can stay in normal mode - even less painful !) Adding quotes for each line : select lines, go in command mode and type - norm yss" - (which relies on tpope's vim-surround plugin) (6 less seconds wasted !) For the sudo trick, if you can't remeber it there's chrisbra's SudoEdit plugin which does this great - :SudoWrite - You can edit multiple files (vim file2 file2 file3), record macro like DT did here and apply it to each file ( - w | n - in command mode to write and go to the next file) With a shell you also can record your macro and do this : # for i in file1 file2 file3; do vim $i -c "norm @o" -c "wq"; done # (o is the name of my macro here) Thank's DT for these tips ! I hope mine are helping you too !
There is no need to reselect the same block again if you want to perform another command, '< and '> will remember the last selected region. And if you really want to select the same region again, just type gv and for changing the `o`ther end of the selection to fine-tune it, just press o If there was whitespace after the last character and you wanted to move the cursor there instead of the very end, there is also g_
After having developed software for more than twenty years, and after having used all of the existing editor and IDEs (including Eclipse, NetBeans, SublimeText, Visual Studio Code, Code::Blocks, Qt Creator, Visual Studio, Atom, etc.), I still CANNOT understand what people see in VI and VIM (That I know and used). History declared a winner a long time ago and it was GUI-based software: it does not make any sense using your memory to store the keyboard shortcuts of CLI-oriented programs when you can have a menu and a sophisticated GUI at your fingertip. I do not even use line editors for configuring servers from remote, anymore. I just use the various "control panels" supplied by the host.
I'm a relatively new vim user. I've passed the initial shock (that's my first modal editor) and the more I use it, the more I like it. On the positive side I love the combination between the vim + vimv in the case of bulk renaming. On the negative side I have a lot more to learn in order to properly use it with another keyboard layouts, which is not very easy if not configured correctly.
i’ve been using vim for years on a dvorak layout pretty much stock. by sheer nature of using vim as long as i have my vimrc has ballooned to be probably a couple hundred lines long but i try not to mess with the default bindings too much!
Hi Derek, love your work. I am fully sold on 'vim', however, I think its a bit disingenuous suggesting that find-replace can take minutes or hours. Even the most basic text editors provide find/replace. The macros feature is definitely a time-saver though. Good vid.
I've used Vim for a couple year, now using VSCode. Vim is great for navigating, selecting and manipulating text. Deep configuration and extending Vim was hard, even after a couple years. VSCode is very comfortable. Extensions mostly "just work". I really love the command palette.
coc.nvim make things "just works" ( even if I don't like that expression) too, without abandoning all the vim goodness not present on vscode ( even with VscodeVim )
20:04 if you do this a lot you can add it to your init.vim or vimrc just add the following "cmap w!! w !sudo tee > /dev/null %" and if you write :w!! and enter it will run this command, it has been in my config for many many years now and it just save me.
As a text editor, vim is great. But I save much more time with an IDE like the ones from Jetbrains when it comes to safe refactoring, debugging, code analysis, etc. I never have to leave the IDE to do anything. And you can even use vim key bindings in them.
You can also select multiple lines holding alt and press end to move cursors to end of each line. I don't know how recording macros to do this is supposed to be superior
Yes, I love how many actions can work from anywhere. Same with dd instead of having to go to the start or end of the line and then doing shift-home or shift-end and backspace.
I don't know... I do 90% of my work on windows PC... and while i was watching this video... i was thinking that i usually do things like that with other editors... for example, the part of the adding or removing quotes... if i have to do something like that with thousands of lines... i just write a regular expression (that i already know because i'm a developer) or simple use a find/replace with things like /n (or /r/n) and achieve the same results, the same to replace a word... Or if i need to indent several lines... i just select the lines (with Shift and Arrows or simply selecting with the mouse) and press tab to ident all of those lines... And i'm talking that i can do that with a simple Notepad++. But of course, in order to do my work, i prefer to use a specialized IDE that in fact save me a lot of time/work. My Favorite IDEs are from JetBrain, they are packed with TONS of features, and is still easy to begin with, because on his core is still working like a normal text editor. That means the learning curve is a lot friendlier, and that time is valuable too. I guess that may some use cases where you need to work with a lot of text files on a remote linux machine... maybe you can use VIM to save time (if you already know how to use VIM). Maybe i'm wrong, and i just can appreciate how great VIM is for most scenarios, but i haven't seen anything "Life changing" here.
It just sounds like DT hasn't spent any time in any modern text editor. I'd really like to have a faceoff between Vim and Subilme/VSCode where we are given an editing task and are timed, to debunk those false "vim saves hours of work" claims. I think 8:59 best proves my point, but any of the examples in this video are easier and faster to do in a modern text editor than in vim. Do yourself a favor and learn modern text editors which aren't notepad or notepad++. You'll save hours of work compared to vim. (yes I know vim including advanced features. yes I am subscribed)
Sublime really lives up to its name. Been using it for years and never looked back. The only times I use VSCode is when I need proper code completion (e.g. when learning a new language or framework), since that's where sublime is a kinda lacking, in my experience, and it's usually pretty damn good in VSCode. SublimeMerge also seems pretty damn good, I might add. Haven't used it much yet, but it's been impressing me. (Also, SublimeText and SublimeMerge have surprisingly low memory and CPU footprints. This is great if you're on a potato, like I am.)
The problem with the above tools mentioned is they are not included by default everywhere. The reason vi/vim is so important. At my work we have many systems with many different OSes most of the systems are closed so no internet access/no permission to install anything. So vi/vim is what you use. For example we had DEC ALPHA with Tru64 with FDDI network. It has vi so does RHEL and most if not all linux distros.
(vscode) 1. moving lines of text well, you can use alt+up/down for moving lines, ctrl+shift+arrow to select a word shift+alt+up(or down) would make another cursor abve, then you can ctrl+l to select a line. And now you 10 lines with 12 keystrokes. 2. looking for text and then moving: ctrl+f and alt+arrow. If you want to grab the next line also alt+shift+up(down)
Multiple Runs of a Macro (21@2) has two problems: First, if an error occurs (e.g. fxx - Find x, delete it - and there is no x in the line, e.g. with an empty line). The complete execution is terminated. The second problem: the macro must go to the next line manually (0j or similar). The "norm" command also helps here. The same macro WITHOUT going to the next line. Select all lines (or enter the line number e.g. line 10 to 20 with :10,20) And then :norm @2 (displayed :'
What I love the most about VIM, is that is has unlimited depth. Literally every video I saw on VIM has this minor tips and tricks which you can incorporate into own workflow
That quote remove example in most editors: Drag select lines you want to remove quotes from. Use find/replace in selection quote with empty character. Hit enter. Literally takes 2 seconds. No need for a macro there.
I think instead of learning these new strange bindings I can just learn regular expressions syntax that is used almost everywhere, so I won't forget it, and with the help of these expressions I can do almost all these tricks in good regular text editor
@@lawrencedoliveiro9104 Actually, simple regular expressions are very easy. My point is that I as a programmer already know them at the level needed for searching in the text editor. I don't need to learn more vim's spells
11:15 DT, that is actually even easier than you did it. You can directly hit "I" (so, shift + i) when visually selecting various lines, and when you do it, even if it SEEMS that what you type next is only being applied to the first line, actually, when you hit escape it will apply it to EVERY line that you had selected! So, no need for ": norm I". Just "I" after selecting and directly type or delete what you want to change at the beginning of those lines!
We received a 6000 page document that was supposed to be a spreadsheet, but it was sent in PDF. Worse that it was "Printed to PDF" which broke the columns up onto 3 different pages. it was a mess. I used a vim macro to solve this. It took me about 45 minutes create the macro and edit this document. learned something new here, I will have to use that !sudo tee % trick
I love the idea and power of VIM and vim clones, and I tried them at least 5 times in the past and in the end went back to my previous editor or whatever. It feels like you need a lifetime to learn the basics and then you discover a plugin that possibly improves your workflow and you need to relearn everything again. But it's true that you can (once you master it) do almost anything very fast. Useful video!!
One of the most useful tricks I like in vim is the ":%" function. I can search and replace portions of text using regular expressions. Example: :%s/apple/orange/g It will replaces all instances of "apple" for "orange" on the entire document. If you are expert in regular expressions, you can do a lot of things with this feature.
fyi, it's the s doing the heavy lifting, not % % is not a substitution function, it is a range specifying the entire file. you can use line numbers too for the range. s means substitute, and g means globally within a line (part of regex syntax) so for example to remove all quotes from lines 10-43: :10,43s/"//g
@@user-lb1ib8rz4h another trick that I like to use is to remove specific line using a pattern. :%/apple/d It removes any line containing the "apple" pattern. Sadly I'm not so good with regular expressions, but the :% function in vim is very useful.
VSCode does everything mentioned in this video plus a ton more. That being said, I appreciate people that still use and maintain 30 year old software (40+ if you count vi).
Every single one of these functions work at least twice as fast on vscode though.. - Having to be the line above the one you're looking for sounds like a great feature! - Moving a line up or down would be faster but not with the example you gave. In vscode you can simple Alt + Arrow key to move it up or down one line at a time, this works with entire selections too. Having to write a line to move it one line is not faster at all. if it was 15-20+ lines then I'd maybe agree but simple cutting and pasting is faster. - Inserting or removing text from multiple lines. In vscode you simply Ctrl (shift on linux) + Alt + Arrow Key. Or even better, you can put a cursor at the end of each line by selecting the text you want to edit and simply press Alt + Shift + I (hit the Home key after if you want it to be at the start, or End to go back to the end of each line. ). No need to write your own scripts/macros and reinvent the wheel. The same way by having multiple cursors you can type in each of the lines, both at the start and the end, no need for a command. - Searching and Replacing text. A whole line of commands on Vim, Ctrl + Shift + H on vscode and simply press Shift + Enter afterwards to replace every instance of the search query, which both accept Regex aswell. - Creating abbreviations I have to agree is faster since you have to write it in json in vscode. But.. rather than pressing space, you press enter in vscode so it doesn't interfere with what you're writing and no need for a shortcut to NOT expand it. - VScode has an integrated terminal and you can open as many instances as you want, no need to enter command mode. tl;dr If you had to write your code inside the terminal then sure Vim is your best friend, but since you tried to throw shade on vscode at the end of the video, Vim has no chance. Every other text editor is much, faster and easier to learn.
Also the indenting can be done by selecting text, and pressing tab. I think his examples were a bit poor. I can see myself using a VSCode extension to emulate some of the VIM keybindings (there is also the NeoVim VSCode integration), so that I can easily select text without having to use my mouse or constantly press control+shift+(right or left arrow) to select a bit of text. In Vim Mode, you would use v to enter visual mode, f and then the character you want to select it to, pressing semicolon as many times as necessary. In normal text editors, holding down control and shift while pressing the arrow keys is quite onerous to select text. Most editors are implementing Vim-like key bindings. There is PSReadline for PowerShell, Obsidian, VSCode as I mentioned earlier through a popular extension, Emacs through Evil mode (Spacemacs too), event Sublime has an extension for it. The problem I see with normal text editors is that as soon as you start shift-selecting text, you cannot search for text that you want end the selection with. Vim (and its variants) has an insert and normal mode to get around this, and in Emacs you can set a mark and then move the cursor to the desired position.
Maybe I don't understand what you're doing, but you don't need to type colon before slash to search. In normal mode, you can simply type the slash key. Done this way, it will search from the beginning of the document.
10:26 you can do that easily in vscode using multicursor. Just go to the beginning of line 11 and then shift+Alt+LMB on the beginning of line 42. Now press Del to remove all opening quotes. To remove closing quotes just press End Backspace. End key just moves every cursor to its end of line. I started learning vim today to maybeeee replace vscode in the future but this feature is so good and I use it so often I might not switch to vim as my main editor ever.
Whatever works for you the best mate. That was not the fastest way to make that edit. Just a simple example. The vim way of doing that is different than the vs code way but I prefer the vim way and it's very fast. Also I can edit my macro with a few key strokes and reuse it for something else without having to do the other selections again. And if your really in love with that there is a vim plugin for it. But again it's personal preference and the vim way is still faster. That being said. Vscode users who knows there keybindings can also get it done. Less the tool and more the person. Whatever works 🎩👍 code on!
The downside is that you have to remember a ton of shortcuts. It's not a problem if you use them regularly, but the rare ones take time to recall - it's easier and faster in other text editors (you just do it with the mouse or right-click for a context menu). Besides, I really need a color-picker and I have never managed to make it work reliably in vim.
Mostly you don't remember anything. They're just mnemonics mostly: Delete Inside Word: diw (it will delete the word where the cursor is inside) Select To
To remove the double quotes from the end of the line can be done like this :10,42s/"$//g $ means end of line. For the beginning of the line, use ^. To add a quote to the begining of lines 10-42. :10,42s/^/"/g. The Ending is :10,42s/$/"/g
What I have done is save it as a random file under /temp, then sudo mv. But yeah thats a much better solution Actually thats what I did in nano, I don't know how to save a file as something in vim. Time to duck it
I really miss some essential plugins in VScode compared to NVIM. For example TailwindCSS intelisense (I know there is one for nvim, but I can't see what those values are - like in vs code pt-3 shows how much padding that will add..)
Well yeah, that's literally with everything. You can save hours of getting from point A to B by driving instead of walking but that would mean you have to spend more time learning how to drive and making money to pay for the car. It doesn't mean it still isn't fast. Learning vim isn't difficult if you are above 8 years old.
@@luck3949 I never said that wasn't true. I'm saying that anything that increases efficiency can take time but that doesn't make it inefficient. Does that make sense to you?
IMO you can use Atom editor and have all those features and more, without learning to do Mortal Kombat fatality for a really simple line editing... Atom: select the text you want to edit at the end, or at the beggining, or after the first word or whatever; Press ctrl + L to enter line mode; Press home to jump to start of all the lines; Press del; Press end to jump to the end; Press backspace. Done in 1 second tops. I do this all the time.
Wait can you regex search and replace in vim? If so makings that one string should just be one command. Maybe vim has more up its sleeve but everything in this video is very possible and honestly simple in VS code, sublime, and the like.
Yeah, i was thinking the same. He probably hasn't looked at modern code-editors for quite a while in detail, just like i haven't spend much time in vim, just knowing enough to feel safe editing in files in a docker container for example. Lets just hope the developers of the editors spent enough time in the respective other editor to learn and copy new effective features some other editor has. For now, most of the time i need more time thinking about what to type, then how to quickly type it.
Almost every editor nowadays are super customizable. After using VIM for a time i only found that if you get used to not touching the mouse it can become very usefull and comfortable, but also if i wanted to i can customize VS Code in a way that i dont need the mice too. I think it comes to a personal opinion of what you like most. Anyways knowing a bit of VIM comes very handy when working on multiple remote linux machines and you need to edit.
Remote + basically knowing vim key bindings gives you the ability to use any editor because most have vim extensions. Today Vscode is the hot product, a week ago it was atom, a month ago it was Sublime. You never know what the next "hot" thing would be, it's far more handy to know vim. + If you really dive into vim real capabilities no other text editor can compare tbh. Edit : And it's way faster than any Electron app, Vscode with large projects/files isn't close to neovim speed
Its interesting, but having watched up to 16:14 the only thing that I actually thing was faster than, say, notepad++ was the adding " to beginnings and endings. All the rest arent as bad as you make it out to be on normal text editors... You are either being disingenuous or you simply never heard of either ctr+f or ctr+h. You dont need to go line by line to remove the " from the selection: just select the portion of the text where you want to make that change, ctr+h, put the " on the find box and leave replace empty, enter, done. Hell, you can find and replace throughout multiple files at once on npp... I think it's actually faster than what you did there, and also much simpler, no need to really think to do this. Change one word? So you are at the word, want to delete it and write on top? Press ctr shift with your left hand and right arrow button. Dont see how the vim way is much quicker...
I think quite a few of these can be used on normal text editors? For instance, moving a line requires Alt + Down/Up Highlighting a whole line requires Shift + End key or Shift + Home key if at end Highlighting multiple lines is just Alt + LMB drag Or maybe I've just been using one text editor that I'm assuming from all pov's
no you're right, a lot of editors have those functionality but slightly diff key binds. it seems like dt hasn't used anything outside of vim in decades
What I think about vim is that, the time it saves doesn't matter as much as the "flow" it gives u, allowing u to do as u think, and not fight the program.
I still remember before I knew Vim doing archaic things like like highlighting text with the mouse, using the narrow keys to slowly navigate, etc. With Vim it's a completely new experience to text editing. And the best part about it, it's future proof. Vim has been around since the early 90s and Vim along with it's variants are still growing. Most modern text editors including sublime text, VSCode, Atom, etc. all have Vim plugins and/or packages. I'm still fairly new to Vim (been using it moderately for about 1 year) and still learning new tricks and shortcuts every day. Bonus points cause usually when peers see you use vim they are impressed or surprised. Cheers to Vim and all the Vim users out there!
ok, most of what you did could be done in sublime text as well fairly easily. i feel that the most important thing is to learn one capable text editor well enough. also sublime text doesn't have such a steep learning curve and i can recommend it to normal ppl. don't get me wrong i like vim, but i mainly use sublime text instead just because i don't have to mess around of how it works. it works well enough for me without touching it. i mess around with vim when i have time and i want to tinker with sth.
I just wanted to ask how you would have done that usnig sublime. I know you can use multi cursor but that is very slow. If you have 500 lines instead of 10 then your process will take much longer but in case of vim time consumption would be same. I guess there is another method to do that in sublime which is faster. If you there is any then please let me know
The video does a terrible job showing what's useful in Vim, to be honest. This guy seems to like writing weird commands, when I barely use those. Vim takes a lot of time to get used to it (and let's not even talk about configuring it, pure nightmare), but it's very satisfying to use once you get it. I would suggest VSCode with the vim extension, specially in Windows.
@@JoePerkins666 I have gave up on windows. I hope I don't have to use for programming ever again. I have build a custom keyboard that gives me mode like navigation in while using my pc. I must say it is enough and because it is not limited to the text editor makes a lot of my navigation better.
Most of the people commenting learning VIM is useless, a waste of time or hard. They didn't understand really the power of it. It's not just looking like a wizard or wining hours of work. Even tho that's what this title says. It's reliability, interopability and comfort for someone who pass alot of it's time on a computer. You don't need to use VIM or clones to profit. VIM shortcuts are a standard in the computer world since 50 years. You can be sure almost every serious computer programs (especially for development) got them integrated or via an extension. And once you know them you can use them everywhere or almost. I switched to Android development recently, in like 2 mins I was like at home after installing one extension in Android Studio. Even to navigate in a web browser. And for those who didn't understand what a modal editor like vim is. It does mean you don't have to learn thousands of commands. But just how the letters interact with each others. You learn a new keycharacter you can mix it with everything you already know. If you have learned that the keyword "c" stands for change, "i" for inside and "w" for word... Then "ciw" is to replace what is in a word, and if 2 mins later you understand that the keycharacter "d" stands for delete then you already know that "diw" will delete what is inside the word. "C" to change a whole line ? then "you know "D" will delete it. Intuitive and not hard like almost every non users says. And to be really honest what you will learn in the vim tutorial which is finished in 30 mins is already way more than enough to use it correctly. And once in a while you will discover a knew keycharacter. To finish almost all the sorcery you have seen there, could have been done way faster way simpler...
If I edited a write protected document (aka needed sudo to edit) and didn't realize until I finished editing, is there a way to basically do "sudo :wq"?
One of my personal favorites that I use pretty much every day at work is vim's grep integration (or ripgrep in my case). Navigating large codebases is super fast if you just have a few keywords/patterns to feed into grep from vim and let it do it's magic, and then just have all the results in the quick fix list for easy access to the files/locations in the file(s).
Had I begun with Linux five to ten years earlier I suspect I'd have been a hardcore vimmer. But today I don't have the time, interest or reason to learn a new text editor. I got some advice years ago: "Choose one text editor and learn it really, really well." _That_ is what will save hours of work. Vim is _one_ editor you can learn well, as is the JetBrains suite or probably emacs.
Learning vim is like going to the gym. You start off knowing it wont give you immediate results and its not gonna be a fun thing, but the more u use it the more effective/fast you re gonna be.
So VSCode can do multi-select, multi cursor, that quote example could be handled by search and replace with use of regex, lines can be moved by alt-arrow, abbreviations are destroyed by snippets, etc. I see the value of having that powerful command palette, but the problem is that we are in 2021, not 1980 and just that won't cut it... Vim would be great with some visualizer so that I could actually use it and learn along the way, you know like regex101.com lists your commands, what will they do, shows you output, and so on. Vim (as it's typically shown) doesn't have anything like that. It expects its user to open the manual and work painfully for days/weeks before it starts to make sense... The fact that the command palette pretty much hijacks your controls, that you can just type anything, there are no hints on what might happen, what you typed and then your file is just destroyed... this really isn't a good user experience. tl;dr: the fact that it cannot "just" be used as a normal editor before the user slowly learns of all of its power is what holds it back and I personally don't think that it's the user's fault, rather than some sort of misguided "power user gatekeeping", that led to where we are now.
I prefer using a graphical editor like Sublime Text or Visual Studio Code / Code OSS but with vim key bindings enabled. This way I can use the mouse when I feel like it, most importantly have a project explorer I can select files with using the mouse, and can still browse around within one file just like I was using vim. Though, a lot of what you're doing here I wou ld handle with regex find / replace. e.g., to remove the double quotes, I'd just replace: ^"(\w+)"$ with \1 or $1 depending on what editor I'm using, an expression to replace it with the value of the first capture group.
Regarding removing double quotes in a normal text editor, it wouldn’t take minutes, you can do alt-select to select columns and then deletes all your double quotes
Ok DT, next time we have a patron talk I now have a new thing to task about besides the Gnome desktop, Defaults Matter, and Microsoft Windows. Because I really don't like Vim for my creative writing.
Honestly not convinced. To play devil's advocate, Comparing this to my favorite text editor (IDEA): - Line shifts are done with holding ALT-shift, then tapping up/down to shift. CTRL-shift would also do contextual shifts (keeping indentation correct, lines of code will 'jump' to the next valid point line between methods instead of in the middle of a method def etc.), something I don't see VIM doing - Blindly search for a line and perform operations on it... Interesting, but I could see me messing that up or spending more time crafting the expression than just doing it in discrete steps. Like, how am I supposed to know where in the document the line should go without seeing both the source and target lines (and then calculating the line number diff), at which point I could've done the shift myself. -There are, of course, keyboard shortcuts for top of document and end of document. There's also browser-style back/forward (seperate from undo/redo) for line positions, and also a view of your recent cursor positions in a menu at CTRL-shift-E. - indenting multiple lines, like most GUI editors, select all and tab/shift-tab. CTRL-W will also do contextual select to avoid the task of finding the line numbers (each tap of 'W' increases selection range. First tap is word, then to first 'punctuation', then to edges of first pair of brackets, then to the next set of braces etc.) - 'Visual mode' (column selection mode/multi-cursor) is just alt-shift-ins. In addition, removing the quotes at the end of the line wouldn't even need a macro in IDEA: just select the line range, and hit 'end' to move each cursor to the end of each respective line. Then one 'backspace' will delete the quotes. Macros work too of course. 'Visual mode' inserts are also much more intuitive (select, home, quote, end, quote) (Cont. in reply)
-Find-replace, including individual inspections before replacement is pretty standard even in basic graphical editors. -Abbreviations are admittedly not as easy to set up, but certainly doable with templates and such, I know some are defined by default. Personally I'd probably forget to hit that shortcut to not expand it in vim but I guess that's nitpicking. I personally use paste history for that (CTRL-shift-V) if I need multiple text blocks in different places. - The shell is accessible via a UI tab (ALT-F12), admittedly not as heavily integrated as it is in vim. The file is saved as soon as the focus switches, and reloaded on another focus switch so e.g. sort/grep would still take effect quickly. Note none of these require mouse interaction even with default keybindings. Any actions that may need the mouse can be searched for with CTRL-shift-A, and bound to a key instead of executing with alt-enter. This UI also doubles as a keybind reference. There's also more intuitive but slower alternatives to most actions so it's all much easier to get into.
Personally I didn't find Vim any advantageous. In part because I don't have an american keyboard, so there's a few default key bindings that don't work, and then having to type ':' before a hotkey or command all the time doesn't seem that handy to me, but especially since my keyboard requires a shift or alt modifier for brackets and (semi-)colons, which makes matters worse. European keyboards aren't as handy for programming as american keyboards are, that's for sure (this is because accents (à, ü, etc) take up the place of brackets and colons in US keyboards). But then, I use Sublime, and my workflow is pretty productive with it, and I don't recall ever seeing people in videos being any more productive using Vim. I can do pretty much the same stuff easily, or in some cases even more easily, in Sublime. I followed some Vim tutorials (some of them yours), but it just kept feeling like taking a step backward or at least not forward, and too much of an investment to learn, with little (if any) bang for the buck. Contrary to most other editors, Vim stalls your productivity down to a crawl at the beginning, with no clear light at the end of the tunnel. Vim movement keys (HJKL) also don't make sense to me (IJKL would), and having to switch modes seems a bit more like a hindrance than not... So yea, to each his own, but personally, I'm still quite unconvinced.
Switching text editors is such a pain to retrain the muscle memory. There is so much inertia behind the use of VIM for people coming to Linux today it's really the only good choice. When I started using Solaris back in the very early 90s Emacs was in more common use in my part of the country (before RUclips of course). Now Emacs doesn't seem to have the steam it used to. Personally the Joe editor has been my bread and butter for such a very long time. I've curated my own way of doing things and tried several times to join the VIM tribe and just can't because of muscle memory and a lack of will to fight against it, lol. :)
VSCode is an IDE, and IDEs want to impose a particular build system on you. In the Open Source world, we deal with a variety of projects that use a whole variety of build systems. It’s not like Windows, where everthing is based on Microsoft’s tools. This makes text editors more versatile than IDEs, because a good text editor, like Emacs, can drive any build system.
@@lawrencedoliveiro9104 VSCode is not an IDE, and imposes no build system on you. Are you perhaps thinking of Visual Studio? But even Visual Studio can be customized to use any build system you want.
nice but what if i have code from a person (maybe me) that uses "east const" such as uint8_t const number=42; and i wanted to change that to const uint8_t number = 42; what i currently would do is dw on const and 0p realisizing that that did not exactly work quite right and then x the erroneous character and either p it where it belongs or just plain retype it there (or just dw on const and retype that where it belongs). so how do you get that done efficiently?
For your exact `Wdw^P` With the cursor position noted as `|` and each line the current state of the line ``` |uint8_t const number=42 # W (Upper W : to go to next WORD, so continuous non whitespace chars) uint8_t |const number=42 # dw (cut from cursor to end of word+space(s) ) uint8_t |number=42 # ^ Go to first non_white space char of the line |uint8_t number=42 # P (Upper P : paste before cursor) |const uint8_t number=42 ``` But I often prefer to use `diw` to allow to redo it with `.` easier, if you automatically format your white spaces `iw` means "inside word" so all of the word regardless of your position inside of it (so your cursor could be anywhere inside "const", not always the first char of it) but it doesn't include the whitespaces So I would personally do `Wdiw^P` by reflex if I auto format my code on save. Also, there is the question of how to run it on multiple lines, the quickest way would be a macro of `dw^P` and * to search next "const" So from the start of the line as previously ``` W # go to start of "const" qa # start a macro to be saved in register "a" (can be any letter, see `:reg` to list all the non-empty registers) dW # cut "const " (space included) ^ # start of "uint8_t" P # paste before * # find next occurrence of the WORD under cursor (here it's the newly pasted "const" ) q # end the recording, saving the keyboard macro in the previously given register (here, its the register "a") ``` After that you can rerun the macro `@a` on the next const that is already under your cursor, if you want. Or you can press `n` to find the next "const" until you find a east const Quick tip: `@@` allow to rerun the latest _run_ macro so you can use it after the first usage of `@a` Also the vim wiki has an article on recursive macros that end on end of buffer (a buffer is often a file) : vim.fandom.com/wiki/Record_a_recursive_macro
I've been using vim (originally vi) for so long that I have a hard time teaching someone how to use it since it's my fingers that know what to do, not my brain! In any case, there's one thing I've occasionally done in vim that I think may be much more time consuming in a lot of other editors, namely editing on the basis of columns. Suppose, for example in the file that was being edited, you wanted to capitalize the first letter of every one of those array elements. Just block select them and type ~. It's also possible to, say, block select the bottom half of the list and then cut and paste it as a second column next to the first half of the list. That ability to invoke an external tool to process (a portion of) your file via the :! construct is extremely powerful. Sorting is an obvious example but I've also used that technique to convert a binary file into a text representation of the contents, do my hacking, then covert back to binary, i.e., I don't need a separate hex editor.
I've seen soooo much content and tutorials for vim but somehow none of them could show anything that I couldn't do with Visual Studio or Notepad++. And those don't need a two-week training course to open a file.
it's silly comparing vim to a standard text editor, cause no one would use a standard text editor to create/edit code. Everything shown here I can do just as fast in any other IDE, but I don't have to remember hotkeys that seem to have been created before any sort of standard was created for them. If you don't already use vim, don't bother learning/using vim
You can do all this in vscode without touching a mouse. And I find it more intuitive. Haven't tried VIM much because I've never found a reason to. I definitely want to edit fast, but I still don't find how VIM can help me with that. Greate video. Thank you.
> Has relative line numbers enabled
> Still does the math to calculate lines
is this 4chan
@@QW3RTYUU Yes 🙂
@@QW3RTYUU No this is Patrick.
@@alejomakevids HAHAHA XDD SO FUNNY meme from 2016
@@mariocamspam72 imagine typing how you laugh
Not having to touch your mouse to use a text editor is underrated. Vim is great for laptops!
You can also use most, if not all, of the existing GUI-based editors and IDEs without touching the mouse: most of them support a large, powerful and configurable set of keyboard shortcuts (that I do not use...).
Its good for desktops too.
It was a nightmare on smartphones though...
still, not much worse than anything else on a smartphone
@@woouinluigh Well unless you have a bluetooth keyboard paired with a tablet or smartphone. Which I've used with tmux / vim a great deal. Actually Mosh + iOS Blink works very well with an unstable cellular connection while on a train. Mosh replaces SSH and provides a much more responsive feel on poor connections. mosh.org simple roaming with session state sync with extremely low latency and local echo so you are not waiting on SSH to catch up.
@@peterjansen4826 Graphical text editors and ide's have been feature equal with Vim and Emacs for decades. There's no feature reason to use Vim over Sublime, Atom, Geany or Kwrite.
I like how genuine dt is, when he makes a mistake he doesn´t edit it out, he shows himself learning it along with us
What mistake?
I appreciate the genuineness, but it does create friction as I absorb and learn
I think learning a new programming language is easier than using the editor
False I need to go bathroom, lol
@@scoutbro9034 of course you can execute a macro and go to bathroom..
@Myungsoo Ya.. they must make a vim OS. Being an editor is a shame..
the fact you have to learn and reseach how to use this editor is a big killer for me, just not worth it.
@@radioactivebob1 You're not required to use 100/100 of vim key bindings and commands. You're still be more productive with the basics than nothing.
+ Taking some time to learn something that will save you time/gives you advantages afterward is an investment, that's what you've probably done when switching from windows/macOs to GNU/Linux or from a DE to a minimal tiling windows manager
11:22 At that point you can just hit I" and that will do the job. Similarly, to add to the end of each line select in block visual mode, then hit $ and A". No need for all that command mode then normal mode trickery.
you can also use block visual mode with ctrl+v and then hit shift+i and it will insert everywhere
you can also use a regex.
That same method could've been used to delete (x) the ” at the end of the line with a comma.
Of all the examples that were given, I’d either never use it, or I can do it faster in sublime. I used Vim for 6 months and I still went back to Sublime. I think it just comes down to personal workflow preference
Copy / Pasting a piece of my comment: "IMHO with the introduction of multi-cursor editors it's time to move on."
@@paolo.iulita Uh, vim can do that. So.
I think a mix of vim and Sublime could actually be a very good workflow. I do that with VSCode and I know there's a vim extension for Sublime. Why don't you give it a try
That's what I was going to say. Each time someone gives me an example supposed to show me Vim's superiority, I can come up with a simpler way to do the same thing in Sublime without having to memorize tons of keybindings and switch mode a bunch of times, and often it happens to be faster.
same
How have I been using Vim keybindings for almost 2 years and i didn't know about :ab that would have been beyond useful many times.
Amazing video DT keep up the amazing content.
I use just vim, but everytime I see someone speaking of advantages of vim, clearly they haven't spend a second loooking up the documentation of other editors.
Every code editor has a lot of features like those of vim.
I mean not really. I use neovim on a daily basis as part of my school classes.
I've run macros more times than I can count and features like that are simply unavailable in other editors.
Sure there are extensions to do stuff like that but then the other editors are already so painfully slow in starting up
@@tanmaydeshpande Yeah, I mean, "a lot" of features, not all. Like, all (or most of) the stuff showed in this video can easily be done in vscode or sublime. But, for example, the integration between vim and the shell is something unique. Vim is awesome for a lot of reasons, but not because you can jump to a line or delete 3 words with a few keystrokes.
@@rogerpenrose1368 eh I think vim is powerful for that as well. Like in normal editors, you can scroll using the mouse or the pgup or pgdn buttons.
In vim you don't need to touch anything apart from your home row for navigation.
Simply press number+j or k and you jump so many lines at once.
And with relative numbering it's even more easy to do stuff like that
@Tanmay Deshpande Yeah... this is an advantage...
@@tanmaydeshpande bruh you are the same guy on some other channel saying "I don't know What is this fuss about Vim" lol
Honestly the IDE's I'm using are all capable of selecting multiple rows, replacing words and swapping lines. If you're comparing Windows Editor to vim, it's obviously more capable of doing stuff. Haven't yet found a feature convincing me to learn vim.
I mainly just like vim's keybinds, they're quick and easy to access. Often you have the same editing power in your IDE of choice with vim bindings as in vim itself (some extensions even use vim as a backend).
You can define more robust keybind and commands with vim than any other editor.
IDEs are only more useful when you're using their features like debugging with realtime memory information graphs.
If you're just editing code then there's literally no reason to use an IDE.
Can your IDE edit multiple configurations from one?
@@iskamag Who cares?
@@christophernuzzi2780 I do, it makes my life so much easier.
nnoremap :move +1
nnoremap :move -2
alt+up/down to move the current line vertically in a classic way
vnoremap :move '>+1gv=gv
vnoremap :move '
A few notes:
- `g;` goes back to the last modification, while `` would be the last cursor position
- to indent a paragraph, you can use `>ap` (`ap` is the paragraph text object)
- to remove the `"` in this context : `vap :s/"//g` (select around paragraph then replace '"' with nothing, `g` to get every match in the line)
Good work though, looking forward for more Vim vids !
Thanks DT. Vim is a powerful editor; I have used it for years. The better you know it, the more time you can save. Great job on the video.
Most vim videos have the same info. But I actually learned something new in the video
There's so much to it. There's always more to learn!
Clouldn't agree more. Just discovered diff-mode editing, visual-block editing, macros, built-in functions like strchars() and getline() in custom mappings and the power of "very" magic regular expressions during the recent decade. For example, removing/adding those quote marks would be one thing I'd use regexp's for, rather than macros.
After all it is all you need...
When you have to go through many videos to learn how to edit text
@@RzariRzari optimization baaabyyyy
I feel so comfortable using Vim and I realized that I know only 0.01% of its features.
To delete ending " instead of macros I prefer %s/"$//g, and I instead of doing "norm" in block mode I use "I", or "A" directly, I don't know if what I do works in all cases. Great vid!
:11,+25 norm 0x$x
That's why I don't understand why guys spend all this time learning Vim when they're never going to use most of it's features. It obvious most are just following the heard and doing what's cool. It's like the sudden popularity of tiling widow managers, it's a fad that will fade.
@@phillipmartin3910 Vim will be 30 years old this year, and vi goes back to the 70s. That's a pretty long fad.
I've been using it as my main editor now for 6 years.
@@phillipmartin3910 Because you want to be efficient and non-distracted. VIM boosts my productivity.
@@umka7536 Ah yes. I so hate when VS Code makes me press End to move all my cursors to the end of the line. Typing in %s/"$//g is so much faster and makes so much more sense.
I will probably end up learning vim anyway, but I find it a bit discoursging how almost everytime someone comes telling how vim is so superior to other programs and it will save you thousands of hours they end up giving some examples that could essily be done in typical programs just as fast, like the example about deleting the double quotes, I could do that in a couple seconds in any editor with multicursor, faster than using a macro.
They are just as ignorant about standard editors as we are about Vim.
After so many years using vim I don't know how but I am still learning new stuffs, amazing. I didn't know about abbreviations. Thank you for the content DT! Keep going!!
Vs code can do cutting/pasting lines, moving lines up/down, navigating to the end/beginning of the document, selecting multiple lines at once, and regex search/replace. All without the mouse... I knew VIM had a hardcore following. It's good to know I'm not missing out with these specific examples of why it's so powerful.
He didn't seem to touch on text objects, which is a very powerful vim feature. The power of vim is also in its ubiquity; its gonna be there on any machine you ssh into and any container you enter into. VScode is excellent but I think the main advantages it has over pure vim is the built in debugger and some of the refactoring tools. You can pimp out vim to do pretty much everything vscode does, but the lack of the debugger is an issue
Sorry man but that's not the case . He's just showing a few percentage of vim capabilities on this video, he would need 10 hours to show what you can do with vim.
It's not still one of the most popular text editor along devs ( 25/100 according to SO ) for nothing even in the GUI age.
With coc.nvim we don't even need vscode anymore.
Feels like learning Regex with extra steps.
yes
You must mean when NOT using VIM, I hope...
The right title should be "Vim can save you seconds of works in a day"
@Henrique Borges aka other text editors save you much more than a couple hours.
@@alexisk1615 Only in the first months. Then it pays off immeasurably
... if you're coming from Notepad.
@Henrique Borges True. Vim wasn't made for me. It was made for incredibly old and outdated operating systems, with weird and convoluted control schemes, and primitive input methods. As for me, i prefer efficiency and ease of use over stubborn nostalgia against all reason.
@Henrique Borges As expected, you're still living in 2010. We have VS Codium here in 2021.
Hi !
A few more tips :
Going back to the last cursor place - g; -
but you can also browse your location stack with - C^O - (backward) and - C^I - (forward)
Indent a whole paragraph (in your case here) : - >ip -
(no need to count, and you can stay in normal mode - even less painful !)
Adding quotes for each line :
select lines, go in command mode and type - norm yss" - (which relies on tpope's vim-surround plugin)
(6 less seconds wasted !)
For the sudo trick, if you can't remeber it there's chrisbra's SudoEdit plugin which does this great - :SudoWrite -
You can edit multiple files (vim file2 file2 file3), record macro like DT did here and apply it to each file ( - w | n - in command mode to write and go to the next file)
With a shell you also can record your macro and do this :
# for i in file1 file2 file3; do vim $i -c "norm @o" -c "wq"; done # (o is the name of my macro here)
Thank's DT for these tips ! I hope mine are helping you too !
There is no need to reselect the same block again if you want to perform another command, '< and '> will remember the last selected region. And if you really want to select the same region again, just type gv and for changing the `o`ther end of the selection to fine-tune it, just press o
If there was whitespace after the last character and you wanted to move the cursor there instead of the very end, there is also g_
After having developed software for more than twenty years, and after having used all of the existing editor and IDEs (including Eclipse, NetBeans, SublimeText, Visual Studio Code, Code::Blocks, Qt Creator, Visual Studio, Atom, etc.), I still CANNOT understand what people see in VI and VIM (That I know and used). History declared a winner a long time ago and it was GUI-based software: it does not make any sense using your memory to store the keyboard shortcuts of CLI-oriented programs when you can have a menu and a sophisticated GUI at your fingertip. I do not even use line editors for configuring servers from remote, anymore. I just use the various "control panels" supplied by the host.
I agree 100%
Must be one of the most practical and easy to watch overviews of Vim out there on RUclips! Great content as usual DT. Many thanks.
I'm a relatively new vim user. I've passed the initial shock (that's my first modal editor) and the more I use it, the more I like it. On the positive side I love the combination between the vim + vimv in the case of bulk renaming. On the negative side I have a lot more to learn in order to properly use it with another keyboard layouts, which is not very easy if not configured correctly.
i’ve been using vim for years on a dvorak layout pretty much stock. by sheer nature of using vim as long as i have my vimrc has ballooned to be probably a couple hundred lines long but i try not to mess with the default bindings too much!
Why use vim when you can use feature rich nano.
Why use nano when you can use minimal Ed
@@alephanull1953 why use ed when you can simply write code in binary on paper
And what is so great about "working faster" anyway? If a mouse slows me down a little (which it doesn't), so what?
The great thing about "working faster" is that it's faster.
Hi Derek, love your work. I am fully sold on 'vim', however, I think its a bit disingenuous suggesting that find-replace can take minutes or hours. Even the most basic text editors provide find/replace. The macros feature is definitely a time-saver though. Good vid.
I've used Vim for a couple year, now using VSCode.
Vim is great for navigating, selecting and manipulating text.
Deep configuration and extending Vim was hard, even after a couple years.
VSCode is very comfortable. Extensions mostly "just work". I really love the command palette.
coc.nvim make things "just works" ( even if I don't like that expression) too, without abandoning all the vim goodness not present on vscode ( even with VscodeVim )
@@heroe1486 only issue coc.nvim is slow as hell because it uses node :( such a shame
We got LSP and treesitter boys. The future is bright
20:04 if you do this a lot you can add it to your init.vim or vimrc just add the following "cmap w!! w !sudo tee > /dev/null %"
and if you write :w!! and enter it will run this command, it has been in my config for many many years now and it just save me.
As a text editor, vim is great. But I save much more time with an IDE like the ones from Jetbrains when it comes to safe refactoring, debugging, code analysis, etc. I never have to leave the IDE to do anything. And you can even use vim key bindings in them.
You can easily swap lines in VSCode with alt+arrow key
i have that shortcut on my vim config
You can also select multiple lines holding alt and press end to move cursors to end of each line. I don't know how recording macros to do this is supposed to be superior
@@radol oh really? How about selecting 2000 lines? Trust me, I've done that in sublime a couple years ago lmao if only I had knew vim
@@maybeanonymous6846 how?? 🤔
@@hil449 to select all of them hold alt then press page down.
My favourite vim commands are o and O. I hated having to hold left or right arrow key and press enter to open a new line above or below.
Yes, I love how many actions can work from anywhere. Same with dd instead of having to go to the start or end of the line and then doing shift-home or shift-end and backspace.
It takes more time/keystrokes and remembering than simple vs-code multi-cursor approach. But it seems more powerful.
13:05 you can use gv to use the last selection again
I see no reason why I should change my text editor...
The way you pronounce "Vim" is amazing
Vyoom
Viəm
I don't know... I do 90% of my work on windows PC... and while i was watching this video... i was thinking that i usually do things like that with other editors... for example, the part of the adding or removing quotes... if i have to do something like that with thousands of lines... i just write a regular expression (that i already know because i'm a developer) or simple use a find/replace with things like /n (or /r/n) and achieve the same results, the same to replace a word... Or if i need to indent several lines... i just select the lines (with Shift and Arrows or simply selecting with the mouse) and press tab to ident all of those lines... And i'm talking that i can do that with a simple Notepad++. But of course, in order to do my work, i prefer to use a specialized IDE that in fact save me a lot of time/work. My Favorite IDEs are from JetBrain, they are packed with TONS of features, and is still easy to begin with, because on his core is still working like a normal text editor. That means the learning curve is a lot friendlier, and that time is valuable too.
I guess that may some use cases where you need to work with a lot of text files on a remote linux machine... maybe you can use VIM to save time (if you already know how to use VIM).
Maybe i'm wrong, and i just can appreciate how great VIM is for most scenarios, but i haven't seen anything "Life changing" here.
It just sounds like DT hasn't spent any time in any modern text editor. I'd really like to have a faceoff between Vim and Subilme/VSCode where we are given an editing task and are timed, to debunk those false "vim saves hours of work" claims. I think 8:59 best proves my point, but any of the examples in this video are easier and faster to do in a modern text editor than in vim.
Do yourself a favor and learn modern text editors which aren't notepad or notepad++. You'll save hours of work compared to vim.
(yes I know vim including advanced features. yes I am subscribed)
Sublime really lives up to its name. Been using it for years and never looked back. The only times I use VSCode is when I need proper code completion (e.g. when learning a new language or framework), since that's where sublime is a kinda lacking, in my experience, and it's usually pretty damn good in VSCode.
SublimeMerge also seems pretty damn good, I might add. Haven't used it much yet, but it's been impressing me.
(Also, SublimeText and SublimeMerge have surprisingly low memory and CPU footprints. This is great if you're on a potato, like I am.)
@@skaruts The problem is Sublime is proprietary garbage.
@@thetreeofclues not a problem to me. It's not an OS, it's just a text editor.
@@skaruts don't see why the scope of the program matters lol
The problem with the above tools mentioned is they are not included by default everywhere. The reason vi/vim is so important. At my work we have many systems with many different OSes most of the systems are closed so no internet access/no permission to install anything. So vi/vim is what you use. For example we had DEC ALPHA with Tru64 with FDDI network. It has vi so does RHEL and most if not all linux distros.
(vscode)
1. moving lines of text
well, you can use alt+up/down for moving lines, ctrl+shift+arrow to select a word shift+alt+up(or down) would make another cursor abve, then you can ctrl+l to select a line. And now you 10 lines with 12 keystrokes.
2. looking for text and then moving: ctrl+f and alt+arrow. If you want to grab the next line also alt+shift+up(down)
Multiple Runs of a Macro (21@2) has two problems:
First, if an error occurs (e.g. fxx - Find x, delete it - and there is no x in the line, e.g. with an empty line). The complete execution is terminated.
The second problem: the macro must go to the next line manually (0j or similar).
The "norm" command also helps here.
The same macro WITHOUT going to the next line. Select all lines (or enter the line number e.g. line 10 to 20 with :10,20)
And then :norm @2 (displayed :'
What I love the most about VIM, is that is has unlimited depth. Literally every video I saw on VIM has this minor tips and tricks which you can incorporate into own workflow
Meh " but [nano,atom,sublime] can do EVERYTHING vim does faster and in a more intuitive way "
That quote remove example in most editors: Drag select lines you want to remove quotes from. Use find/replace in selection quote with empty character. Hit enter. Literally takes 2 seconds. No need for a macro there.
I think instead of learning these new strange bindings I can just learn regular expressions syntax that is used almost everywhere, so I won't forget it, and with the help of these expressions I can do almost all these tricks in good regular text editor
Quoth Jamie Zawinski: “A programmer has a problem, and thinks: “I know-I’ll use a regular expression to solve it”. Now they have _two_ problems.”
@@lawrencedoliveiro9104 Actually, simple regular expressions are very easy. My point is that I as a programmer already know them at the level needed for searching in the text editor. I don't need to learn more vim's spells
@@vitiok78 It’s not either/or.
@@vitiok78 you can use regex in vim too lol
:10,43s/"//g
would've removed all the quotes in those specified lines too
11:15 DT, that is actually even easier than you did it. You can directly hit "I" (so, shift + i) when visually selecting various lines, and when you do it, even if it SEEMS that what you type next is only being applied to the first line, actually, when you hit escape it will apply it to EVERY line that you had selected!
So, no need for ": norm I". Just "I" after selecting and directly type or delete what you want to change at the beginning of those lines!
The double quote staff can be easily done with any editor (notepad++, for example) with multiple cursor support. That includes almost every ide.
We received a 6000 page document that was supposed to be a spreadsheet, but it was sent in PDF. Worse that it was "Printed to PDF" which broke the columns up onto 3 different pages. it was a mess. I used a vim macro to solve this. It took me about 45 minutes create the macro and edit this document. learned something new here, I will have to use that !sudo tee % trick
I love the idea and power of VIM and vim clones, and I tried them at least 5 times in the past and in the end went back to my previous editor or whatever. It feels like you need a lifetime to learn the basics and then you discover a plugin that possibly improves your workflow and you need to relearn everything again.
But it's true that you can (once you master it) do almost anything very fast.
Useful video!!
One of the most useful tricks I like in vim is the ":%" function. I can search and replace portions of text using regular expressions. Example:
:%s/apple/orange/g
It will replaces all instances of "apple" for "orange" on the entire document. If you are expert in regular expressions, you can do a lot of things with this feature.
fyi, it's the s doing the heavy lifting, not %
% is not a substitution function, it is a range specifying the entire file. you can use line numbers too for the range. s means substitute, and g means globally within a line (part of regex syntax)
so for example to remove all quotes from lines 10-43:
:10,43s/"//g
@@user-lb1ib8rz4h another trick that I like to use is to remove specific line using a pattern.
:%/apple/d
It removes any line containing the "apple" pattern.
Sadly I'm not so good with regular expressions, but the :% function in vim is very useful.
VSCode does everything mentioned in this video plus a ton more. That being said, I appreciate people that still use and maintain 30 year old software (40+ if you count vi).
"plus a ton more" as if he mentioned everything you can do in vim
Haven't watched your channel in awhile but that beard looks great on you!
Hey, thanks!
Every single one of these functions work at least twice as fast on vscode though..
- Having to be the line above the one you're looking for sounds like a great feature!
- Moving a line up or down would be faster but not with the example you gave. In vscode you can simple Alt + Arrow key to move it up or down one line at a time, this works with entire selections too. Having to write a line to move it one line is not faster at all. if it was 15-20+ lines then I'd maybe agree but simple cutting and pasting is faster.
- Inserting or removing text from multiple lines. In vscode you simply Ctrl (shift on linux) + Alt + Arrow Key.
Or even better, you can put a cursor at the end of each line by selecting the text you want to edit and simply press Alt + Shift + I (hit the Home key after if you want it to be at the start, or End to go back to the end of each line. ). No need to write your own scripts/macros and reinvent the wheel.
The same way by having multiple cursors you can type in each of the lines, both at the start and the end, no need for a command.
- Searching and Replacing text. A whole line of commands on Vim, Ctrl + Shift + H on vscode and simply press Shift + Enter afterwards to replace every instance of the search query, which both accept Regex aswell.
- Creating abbreviations I have to agree is faster since you have to write it in json in vscode.
But.. rather than pressing space, you press enter in vscode so it doesn't interfere with what you're writing and no need for a shortcut to NOT expand it.
- VScode has an integrated terminal and you can open as many instances as you want, no need to enter command mode.
tl;dr If you had to write your code inside the terminal then sure Vim is your best friend, but since you tried to throw shade on vscode at the end of the video, Vim has no chance. Every other text editor is much, faster and easier to learn.
Also the indenting can be done by selecting text, and pressing tab.
I think his examples were a bit poor. I can see myself using a VSCode extension to emulate some of the VIM keybindings (there is also the NeoVim VSCode integration), so that I can easily select text without having to use my mouse or constantly press control+shift+(right or left arrow) to select a bit of text. In Vim Mode, you would use v to enter visual mode, f and then the character you want to select it to, pressing semicolon as many times as necessary. In normal text editors, holding down control and shift while pressing the arrow keys is quite onerous to select text.
Most editors are implementing Vim-like key bindings. There is PSReadline for PowerShell, Obsidian, VSCode as I mentioned earlier through a popular extension, Emacs through Evil mode (Spacemacs too), event Sublime has an extension for it.
The problem I see with normal text editors is that as soon as you start shift-selecting text, you cannot search for text that you want end the selection with. Vim (and its variants) has an insert and normal mode to get around this, and in Emacs you can set a mark and then move the cursor to the desired position.
I've been using vim for maybe 3 months with a couple of plugins and it is awesome! This video added a couple of tools to my toolbox. Good video DT
Maybe I don't understand what you're doing, but you don't need to type colon before slash to search. In normal mode, you can simply type the slash key. Done this way, it will search from the beginning of the document.
10:26 you can do that easily in vscode using multicursor.
Just go to the beginning of line 11 and then shift+Alt+LMB on the beginning of line 42. Now press Del to remove all opening quotes. To remove closing quotes just press End Backspace. End key just moves every cursor to its end of line.
I started learning vim today to maybeeee replace vscode in the future but this feature is so good and I use it so often I might not switch to vim as my main editor ever.
Whatever works for you the best mate. That was not the fastest way to make that edit. Just a simple example. The vim way of doing that is different than the vs code way but I prefer the vim way and it's very fast. Also I can edit my macro with a few key strokes and reuse it for something else without having to do the other selections again. And if your really in love with that there is a vim plugin for it. But again it's personal preference and the vim way is still faster. That being said. Vscode users who knows there keybindings can also get it done. Less the tool and more the person. Whatever works 🎩👍 code on!
There is also multicursor for vim
The downside is that you have to remember a ton of shortcuts. It's not a problem if you use them regularly, but the rare ones take time to recall - it's easier and faster in other text editors (you just do it with the mouse or right-click for a context menu).
Besides, I really need a color-picker and I have never managed to make it work reliably in vim.
Mostly you don't remember anything. They're just mnemonics mostly:
Delete Inside Word: diw (it will delete the word where the cursor is inside)
Select To
To remove the double quotes from the end of the line can be done like this :10,42s/"$//g $ means end of line. For the beginning of the line, use ^. To add a quote to the begining of lines 10-42. :10,42s/^/"/g. The Ending is :10,42s/$/"/g
Sweet. Need more VIM videos, please!
See ruclips.net/video/XA2WjJbmmoM/видео.html I need to rewatch that now that I actually use vim
that last command will save me hours of editing /etc config files, thanks dt
What I have done is save it as a random file under /temp, then sudo mv. But yeah thats a much better solution
Actually thats what I did in nano, I don't know how to save a file as something in vim. Time to duck it
i learnt vim just little back. very good editor
When you edit the array contents, half of the time you don't need to enter command mode, just press I and you can add the " at the start for example.
I don't find macros to be nearly as useful as :global (“:g”) and :substitute (“:s”). To get rid of all the quotation marks, it's just :'
yea, but what if you don't want to delete ALL quotation marks, but on a specific range of lines?
@@kardashevr I usually use visual mode for that.
@@atimholt cool!
@@kardashevr:start_n,stop_ns///[modifiers]
.,+5s will sub from current line to next 5
-5,+5s will sub from prev 5 to next 5
I’ve been using vim for past 20 years and never used abbreviations command! Vim multiple files opened as buffers can do wonders.
I really miss some essential plugins in VScode compared to NVIM. For example TailwindCSS intelisense (I know there is one for nvim, but I can't see what those values are - like in vs code pt-3 shows how much padding that will add..)
Vim can save you hours of work*
*After spending tens of hours on configuring and learning vim.
Well yeah, that's literally with everything. You can save hours of getting from point A to B by driving instead of walking but that would mean you have to spend more time learning how to drive and making money to pay for the car. It doesn't mean it still isn't fast.
Learning vim isn't difficult if you are above 8 years old.
@@nomathic7672 or you can just use jetbrains IDEs that are intuitive and work out of the box just fine.
more like hundreds thousands
@@luck3949 I never said that wasn't true. I'm saying that anything that increases efficiency can take time but that doesn't make it inefficient.
Does that make sense to you?
Honestly, developers that can't even understand their own points scare me.
What about Kakoune. I know you did a video on it but I'm still wondering
IMO you can use Atom editor and have all those features and more, without learning to do Mortal Kombat fatality for a really simple line editing...
Atom: select the text you want to edit at the end, or at the beggining, or after the first word or whatever; Press ctrl + L to enter line mode; Press home to jump to start of all the lines; Press del; Press end to jump to the end; Press backspace. Done in 1 second tops. I do this all the time.
You'd have the time to finish rewrite the Linux kernel in rust in Vim before Atom even launched to be honest
Wait can you regex search and replace in vim? If so makings that one string should just be one command. Maybe vim has more up its sleeve but everything in this video is very possible and honestly simple in VS code, sublime, and the like.
Yeah, i was thinking the same.
He probably hasn't looked at modern code-editors for quite a while in detail,
just like i haven't spend much time in vim, just knowing enough to feel safe editing in files in a docker container for example.
Lets just hope the developers of the editors spent enough time in the respective other editor to learn and copy new effective features some other editor has.
For now, most of the time i need more time thinking about what to type, then how to quickly type it.
If you use WSL, use ctrl+q instead of ctrl+v to prevent the abbreviation from expanding.
Another great Vim video DT. You make learning Vim easier, thanks mate.
Almost every editor nowadays are super customizable. After using VIM for a time i only found that if you get used to not touching the mouse it can become very usefull and comfortable, but also if i wanted to i can customize VS Code in a way that i dont need the mice too.
I think it comes to a personal opinion of what you like most. Anyways knowing a bit of VIM comes very handy when working on multiple remote linux machines and you need to edit.
Remote + basically knowing vim key bindings gives you the ability to use any editor because most have vim extensions. Today Vscode is the hot product, a week ago it was atom, a month ago it was Sublime. You never know what the next "hot" thing would be, it's far more handy to know vim.
+ If you really dive into vim real capabilities no other text editor can compare tbh.
Edit : And it's way faster than any Electron app, Vscode with large projects/files isn't close to neovim speed
To move a line, I use alt+arrow key
I don’t think VIM is any faster
You can just use the arrow key, no problem. Or the traditional "h, j, k, l" key.
Its interesting, but having watched up to 16:14 the only thing that I actually thing was faster than, say, notepad++ was the adding " to beginnings and endings. All the rest arent as bad as you make it out to be on normal text editors... You are either being disingenuous or you simply never heard of either ctr+f or ctr+h. You dont need to go line by line to remove the " from the selection: just select the portion of the text where you want to make that change, ctr+h, put the " on the find box and leave replace empty, enter, done. Hell, you can find and replace throughout multiple files at once on npp... I think it's actually faster than what you did there, and also much simpler, no need to really think to do this. Change one word? So you are at the word, want to delete it and write on top? Press ctr shift with your left hand and right arrow button. Dont see how the vim way is much quicker...
"Can your editor compete with vim?"
Me: Well yeah! my vim is great too. Of course it could compete with yours
Used Vim for a long time, but vscode is just better for my work. Best thing microsoft did.
You can emulate Vim in vscode. So definite win there....
I think quite a few of these can be used on normal text editors?
For instance, moving a line requires Alt + Down/Up
Highlighting a whole line requires Shift + End key or Shift + Home key if at end
Highlighting multiple lines is just Alt + LMB drag
Or maybe I've just been using one text editor that I'm assuming from all pov's
no you're right, a lot of editors have those functionality but slightly diff key binds. it seems like dt hasn't used anything outside of vim in decades
What I think about vim is that, the time it saves doesn't matter as much as the "flow" it gives u, allowing u to do as u think, and not fight the program.
I still remember before I knew Vim doing archaic things like like highlighting text with the mouse, using the narrow keys to slowly navigate, etc.
With Vim it's a completely new experience to text editing. And the best part about it, it's future proof. Vim has been around since the early 90s and Vim along with it's variants are still growing. Most modern text editors including sublime text, VSCode, Atom, etc. all have Vim plugins and/or packages.
I'm still fairly new to Vim (been using it moderately for about 1 year) and still learning new tricks and shortcuts every day. Bonus points cause usually when peers see you use vim they are impressed or surprised.
Cheers to Vim and all the Vim users out there!
ok, most of what you did could be done in sublime text as well fairly easily. i feel that the most important thing is to learn one capable text editor well enough. also sublime text doesn't have such a steep learning curve and i can recommend it to normal ppl. don't get me wrong i like vim, but i mainly use sublime text instead just because i don't have to mess around of how it works. it works well enough for me without touching it. i mess around with vim when i have time and i want to tinker with sth.
I just wanted to ask how you would have done that usnig sublime. I know you can use multi cursor but that is very slow. If you have 500 lines instead of 10 then your process will take much longer but in case of vim time consumption would be same. I guess there is another method to do that in sublime which is faster.
If you there is any then please let me know
The video does a terrible job showing what's useful in Vim, to be honest. This guy seems to like writing weird commands, when I barely use those. Vim takes a lot of time to get used to it (and let's not even talk about configuring it, pure nightmare), but it's very satisfying to use once you get it. I would suggest VSCode with the vim extension, specially in Windows.
@@JoePerkins666 I have gave up on windows. I hope I don't have to use for programming ever again. I have build a custom keyboard that gives me mode like navigation in while using my pc. I must say it is enough and because it is not limited to the text editor makes a lot of my navigation better.
the usage of norm and that cgn + colon is really neat
Most of the people commenting learning VIM is useless, a waste of time or hard. They didn't understand really the power of it. It's not just looking like a wizard or wining hours of work. Even tho that's what this title says. It's reliability, interopability and comfort for someone who pass alot of it's time on a computer.
You don't need to use VIM or clones to profit. VIM shortcuts are a standard in the computer world since 50 years. You can be sure almost every serious computer programs (especially for development) got them integrated or via an extension. And once you know them you can use them everywhere or almost.
I switched to Android development recently, in like 2 mins I was like at home after installing one extension in Android Studio. Even to navigate in a web browser.
And for those who didn't understand what a modal editor like vim is. It does mean you don't have to learn thousands of commands. But just how the letters interact with each others.
You learn a new keycharacter you can mix it with everything you already know. If you have learned that the keyword "c" stands for change, "i" for inside and "w" for word... Then "ciw" is to replace what is in a word, and if 2 mins later you understand that the keycharacter "d" stands for delete then you already know that "diw" will delete what is inside the word. "C" to change a whole line ? then "you know "D" will delete it. Intuitive and not hard like almost every non users says. And to be really honest what you will learn in the vim tutorial which is finished in 30 mins is already way more than enough to use it correctly. And once in a while you will discover a knew keycharacter.
To finish almost all the sorcery you have seen there, could have been done way faster way simpler...
If I edited a write protected document (aka needed sudo to edit) and didn't realize until I finished editing, is there a way to basically do "sudo :wq"?
Figured it out...
:w !sudo tee % > /dev/null
Find it by running :hE212 in vim
One of my personal favorites that I use pretty much every day at work is vim's grep integration (or ripgrep in my case). Navigating large codebases is super fast if you just have a few keywords/patterns to feed into grep from vim and let it do it's magic, and then just have all the results in the quick fix list for easy access to the files/locations in the file(s).
Had I begun with Linux five to ten years earlier I suspect I'd have been a hardcore vimmer. But today I don't have the time, interest or reason to learn a new text editor.
I got some advice years ago: "Choose one text editor and learn it really, really well." _That_ is what will save hours of work. Vim is _one_ editor you can learn well, as is the JetBrains suite or probably emacs.
I notice some art in your terminals, Bomberman, pacman, etc. What program is that?
I had no idea Vim was that awesome! Thanks a lot.
Which resource would your recommend to someone looking for mastering Vim?
Learning vim is like going to the gym. You start off knowing it wont give you immediate results and its not gonna be a fun thing, but the more u use it the more effective/fast you re gonna be.
So VSCode can do multi-select, multi cursor, that quote example could be handled by search and replace with use of regex, lines can be moved by alt-arrow, abbreviations are destroyed by snippets, etc.
I see the value of having that powerful command palette, but the problem is that we are in 2021, not 1980 and just that won't cut it... Vim would be great with some visualizer so that I could actually use it and learn along the way, you know like regex101.com lists your commands, what will they do, shows you output, and so on. Vim (as it's typically shown) doesn't have anything like that. It expects its user to open the manual and work painfully for days/weeks before it starts to make sense... The fact that the command palette pretty much hijacks your controls, that you can just type anything, there are no hints on what might happen, what you typed and then your file is just destroyed... this really isn't a good user experience.
tl;dr: the fact that it cannot "just" be used as a normal editor before the user slowly learns of all of its power is what holds it back and I personally don't think that it's the user's fault, rather than some sort of misguided "power user gatekeeping", that led to where we are now.
I prefer using a graphical editor like Sublime Text or Visual Studio Code / Code OSS but with vim key bindings enabled. This way I can use the mouse when I feel like it, most importantly have a project explorer I can select files with using the mouse, and can still browse around within one file just like I was using vim.
Though, a lot of what you're doing here I wou ld handle with regex find / replace. e.g., to remove the double quotes, I'd just replace:
^"(\w+)"$
with
\1 or $1 depending on what editor I'm using, an expression to replace it with the value of the first capture group.
Regarding removing double quotes in a normal text editor, it wouldn’t take minutes, you can do alt-select to select columns and then deletes all your double quotes
Good video otherwise, thank you :)
Ok DT, next time we have a patron talk I now have a new thing to task about besides the Gnome desktop, Defaults Matter, and Microsoft Windows. Because I really don't like Vim for my creative writing.
Honestly not convinced. To play devil's advocate, Comparing this to my favorite text editor (IDEA):
- Line shifts are done with holding ALT-shift, then tapping up/down to shift. CTRL-shift would also do contextual shifts (keeping indentation correct, lines of code will 'jump' to the next valid point line between methods instead of in the middle of a method def etc.), something I don't see VIM doing
- Blindly search for a line and perform operations on it... Interesting, but I could see me messing that up or spending more time crafting the expression than just doing it in discrete steps. Like, how am I supposed to know where in the document the line should go without seeing both the source and target lines (and then calculating the line number diff), at which point I could've done the shift myself.
-There are, of course, keyboard shortcuts for top of document and end of document. There's also browser-style back/forward (seperate from undo/redo) for line positions, and also a view of your recent cursor positions in a menu at CTRL-shift-E.
- indenting multiple lines, like most GUI editors, select all and tab/shift-tab. CTRL-W will also do contextual select to avoid the task of finding the line numbers (each tap of 'W' increases selection range. First tap is word, then to first 'punctuation', then to edges of first pair of brackets, then to the next set of braces etc.)
- 'Visual mode' (column selection mode/multi-cursor) is just alt-shift-ins. In addition, removing the quotes at the end of the line wouldn't even need a macro in IDEA: just select the line range, and hit 'end' to move each cursor to the end of each respective line. Then one 'backspace' will delete the quotes. Macros work too of course. 'Visual mode' inserts are also much more intuitive (select, home, quote, end, quote)
(Cont. in reply)
-Find-replace, including individual inspections before replacement is pretty standard even in basic graphical editors.
-Abbreviations are admittedly not as easy to set up, but certainly doable with templates and such, I know some are defined by default. Personally I'd probably forget to hit that shortcut to not expand it in vim but I guess that's nitpicking. I personally use paste history for that (CTRL-shift-V) if I need multiple text blocks in different places.
- The shell is accessible via a UI tab (ALT-F12), admittedly not as heavily integrated as it is in vim. The file is saved as soon as the focus switches, and reloaded on another focus switch so e.g. sort/grep would still take effect quickly.
Note none of these require mouse interaction even with default keybindings. Any actions that may need the mouse can be searched for with CTRL-shift-A, and bound to a key instead of executing with alt-enter. This UI also doubles as a keybind reference. There's also more intuitive but slower alternatives to most actions so it's all much easier to get into.
Personally I didn't find Vim any advantageous. In part because I don't have an american keyboard, so there's a few default key bindings that don't work, and then having to type ':' before a hotkey or command all the time doesn't seem that handy to me, but especially since my keyboard requires a shift or alt modifier for brackets and (semi-)colons, which makes matters worse. European keyboards aren't as handy for programming as american keyboards are, that's for sure (this is because accents (à, ü, etc) take up the place of brackets and colons in US keyboards).
But then, I use Sublime, and my workflow is pretty productive with it, and I don't recall ever seeing people in videos being any more productive using Vim. I can do pretty much the same stuff easily, or in some cases even more easily, in Sublime. I followed some Vim tutorials (some of them yours), but it just kept feeling like taking a step backward or at least not forward, and too much of an investment to learn, with little (if any) bang for the buck. Contrary to most other editors, Vim stalls your productivity down to a crawl at the beginning, with no clear light at the end of the tunnel. Vim movement keys (HJKL) also don't make sense to me (IJKL would), and having to switch modes seems a bit more like a hindrance than not...
So yea, to each his own, but personally, I'm still quite unconvinced.
Switching text editors is such a pain to retrain the muscle memory. There is so much inertia behind the use of VIM for people coming to Linux today it's really the only good choice. When I started using Solaris back in the very early 90s Emacs was in more common use in my part of the country (before RUclips of course). Now Emacs doesn't seem to have the steam it used to.
Personally the Joe editor has been my bread and butter for such a very long time. I've curated my own way of doing things and tried several times to join the VIM tribe and just can't because of muscle memory and a lack of will to fight against it, lol. :)
Hmm.. interesting
11:23 Dt has no idea regarding VSCode. Don't get me wrong, I use vim for everything else, but for heavy projects with huge files, I use VSCode.
vscode also has a vim plugin tho.
@@arman97 Yeah I already use that.... I am habituated with Vim bindings too much
VSCode is an IDE, and IDEs want to impose a particular build system on you. In the Open Source world, we deal with a variety of projects that use a whole variety of build systems. It’s not like Windows, where everthing is based on Microsoft’s tools. This makes text editors more versatile than IDEs, because a good text editor, like Emacs, can drive any build system.
@@lawrencedoliveiro9104 VSCode is not an IDE, and imposes no build system on you. Are you perhaps thinking of Visual Studio? But even Visual Studio can be customized to use any build system you want.
@@armpitpuncher Emacs doesn’t need “customizing” to use any build system: it can already invoke the necessary build commands.
Love your content DT! Happy New year!
nice but what if i have code from a person (maybe me) that uses "east const" such as uint8_t const number=42; and i wanted to change that to const uint8_t number = 42; what i currently would do is dw on const and 0p realisizing that that did not exactly work quite right and then x the erroneous character and either p it where it belongs or just plain retype it there (or just dw on const and retype that where it belongs). so how do you get that done efficiently?
For your exact `Wdw^P`
With the cursor position noted as `|` and each line the current state of the line
```
|uint8_t const number=42
# W (Upper W : to go to next WORD, so continuous non whitespace chars)
uint8_t |const number=42
# dw (cut from cursor to end of word+space(s) )
uint8_t |number=42
# ^ Go to first non_white space char of the line
|uint8_t number=42
# P (Upper P : paste before cursor)
|const uint8_t number=42
```
But I often prefer to use `diw` to allow to redo it with `.` easier, if you automatically format your white spaces
`iw` means "inside word" so all of the word regardless of your position inside of it
(so your cursor could be anywhere inside "const", not always the first char of it)
but it doesn't include the whitespaces
So I would personally do `Wdiw^P` by reflex if I auto format my code on save.
Also, there is the question of how to run it on multiple lines,
the quickest way would be a macro of `dw^P` and * to search next "const"
So from the start of the line as previously
```
W # go to start of "const"
qa # start a macro to be saved in register "a" (can be any letter, see `:reg` to list all the non-empty registers)
dW # cut "const " (space included)
^ # start of "uint8_t"
P # paste before
* # find next occurrence of the WORD under cursor (here it's the newly pasted "const" )
q # end the recording, saving the keyboard macro in the previously given register (here, its the register "a")
```
After that you can rerun the macro `@a` on the next const that is already under your cursor, if you want.
Or you can press `n` to find the next "const" until you find a east const
Quick tip: `@@` allow to rerun the latest _run_ macro so you can use it after the first usage of `@a`
Also the vim wiki has an article on recursive macros that end on end of buffer (a buffer is often a file) : vim.fandom.com/wiki/Record_a_recursive_macro
@@rafeu2288 wow that is a very thourogh explaination. didnt realize there is a difference between p and P which i guess is the main take away...
I've been using vim (originally vi) for so long that I have a hard time teaching someone how to use it since it's my fingers that know what to do, not my brain!
In any case, there's one thing I've occasionally done in vim that I think may be much more time consuming in a lot of other editors, namely editing on the basis of columns. Suppose, for example in the file that was being edited, you wanted to capitalize the first letter of every one of those array elements. Just block select them and type ~. It's also possible to, say, block select the bottom half of the list and then cut and paste it as a second column next to the first half of the list.
That ability to invoke an external tool to process (a portion of) your file via the :! construct is extremely powerful. Sorting is an obvious example but I've also used that technique to convert a binary file into a text representation of the contents, do my hacking, then covert back to binary, i.e., I don't need a separate hex editor.
Last two weeks I spent around 30 hours customizing my neovim, zsh and tmux setup. Very efficient))
I've seen soooo much content and tutorials for vim but somehow none of them could show anything that I couldn't do with Visual Studio or Notepad++. And those don't need a two-week training course to open a file.
it's silly comparing vim to a standard text editor, cause no one would use a standard text editor to create/edit code. Everything shown here I can do just as fast in any other IDE, but I don't have to remember hotkeys that seem to have been created before any sort of standard was created for them.
If you don't already use vim, don't bother learning/using vim
You can do all this in vscode without touching a mouse. And I find it more intuitive. Haven't tried VIM much because I've never found a reason to. I definitely want to edit fast, but I still don't find how VIM can help me with that.
Greate video. Thank you.