I like how there are youtubers that are suffering from "creativity crisis" running out of ideas for new videos, and then there are linux youtubers getting infinite inspiration from manuals. 10/10 content
This thumbnail is the greatest thing I’ve ever seen. DT is the best Linux channel on UA-cam, period. These videos are well scripted and easy to follow. I have learned more from DT than any other single source. Thank you for the great content.
I like to use the normal command with the global command. One example I use when I install Arch that many of you will probably find useful is going into /etc/pacman.d/mirrorlist and doing: :g/## United States/normal VjdGp That moves all of the mirrors from the US to the bottom of the document so I can just do: gg6jV/United Stateskd And now my mirror list is all from the US. But a nice thing to know is that you can combine it with macros. Basically, you go to a line you would want to affect, start recording a macro only on that line, stop recording the macro, then call the macro in the global command prompt. This is handy when you're doing a complex macro on a ton of lines because just doing the global command can be confusing since you don't visually see what's happening. And making the macro in a way that it does the stuff, goes to the next instance, then redoes it can be extremely slow. For an extremely simplified example, if you want to put the word "foo" as the second to last word of any line that says "bar" already, you can do: qw$Bifoo q :g/bar/normal @w And if you have a long macro and/or a lot of lines to do it on, it's much faster than recording the same macro except making it go to the next instance as well, and then doing 100@w or something like that. And finally, if you need to use a special character/key in the global call, like you need to emulate the person pressing the enter button, just press ctrl+v and then the button.
One of the most powerful global command applications in my opinion is in combination with the `normal` command. It lets you execute a sequence of keypresses as if they were typed from normal mode. This way you can have something like :g/^\s*int/normal ^cwlong to replace every line starting with int to start with long instead. Just something I came up with in the moment but the possibilities are endless. You can kind of think of it as a multiple cursor implementation of sublime text in vim.
:.write command is actually pretty useful when you are editing a script and want to test one of the line. Indeed, you can redirect the output of the write command to the stdin of any other process. :.write !bash would execute the particular line you are on and see the ouput from your shell (here I choose bash but obviously could be any shell)
An interesting addition to the :g command not mentioned is that it can also take a range itself, limiting its "global" scope to whatever section of the file you want. So to reverse only lines 10-20 in your file: :10,20g/^/ m9 Note that you move the matched lines to one above the point you want the insertion to start at. You can also nest multiple global commands. One slightly tricky gotcha with :g is that it always needs to include a match string. This means that to use :s with it instead of %, you would need: g/^/ s/foo/bar/ Combine all the multiple ranges and matches available and you can target quite complex and powerful selections.
I knew about running shell commands with :! and I knew about using :read command to paste file contents. But I didn't think of using :read ! to paste the shell output. Very useful!
Thanks for a very informative video, Derek! This helps to nudge my vim-fu ahead another baby step. Once thing I discovered on my own was doing a Visual or Visual Line and hitting colon, which puts the selected range on the command line, ready for a substitution, etc. Cheers.
00:36 command mode intro 00:58 run shell commands from vim 01:37 read a shell command's output and put it to the current line, e.g. :read !date 02:41 :$read !date
Wow, this was a really good vim tutorial! Most of the things you showed had real practical uses, which is great, because I can already imagine myself using them.
Interesting... In most cases I find it easier to mark ranges with visual line mode. You can then type a colon which brings you into command mode with your range already specified, and you can add what ever you want, like substitutions, write to a new file, and so on
This is so whack today I used the :%s /pattern/replace/g command today in some C++ programming and I googled "What does g command do in vim" and it all didn't make sense to me, your video shows me not only what g does but also what % does and so much more. Funny how sometimes you don't even got to search for what you were trying to figure out earlier and it pops in your reccomended when you are subbed to some good channels. 🙌
Hey DT, could you make a video installing Arch, a window manager and ricing it from scratch? Nothing really extreme, just basic stuff. Cheers from Brazil!
Love this. I have just been getting into VIM and learning new and more useful commands and bam I run into your video showing me even some more to add to my list. Awesome stuff. btw - VIFM is another great command line file browser (like ranger) related to VI so maybe you could talk more on that too.
Hey DT, have you heard of Kakoune? I learned about it in the comments of one of your videos. It’s reminiscent of Vim but tries to stick to the Unix philosophy better. In particular, it gives visual feedback to commands and relies heavily on what it calls “selections”. Great video, as always!
...and I thought I knew enough but this is superb, thanks :D I wrote this too fast.. holy crap what you can do in there!! Can I move to your place for like 3-5 months or so for some real cram of Linux :P
but can you use g to move stuff to a different file (say move all source code in a latex document to an external file you can then import, instead of being put in verbatim)
Crikey. Yesterday, I found myself having to reverse a file for the first time in my life. Googled and found a sed oneliner. Happy. Today, this pops up first in my UA-cam recommendations! Now paranoid...
when using mode() to display in my StatusLine, why does it never show 'c' for COMMAND, it remains as NORMAL and the mode() function does not return 'c'. For insert mode it changes to 'I' but never changes to 'c' when entering into COMMAND like yours does. Am I missing something?
Quick question Mr DT or anyone else that wants to answer. I've just bought a new ASUS laptop that has a 4k screen. Does Ubuntu or any of the flavours of Ubuntu 20.04 (MATE etc) work ok in 4k?
Hey, Can you please make a video about how we can have follow-mode in Emacs inside vim/nvim? There are some tutorials about :set cursorbind and :set scrollbind in vim, but they don't do the follow-mode job. thank you!
You quarantined by a nuclear reactor? Cause in my neck of the woods, ppl usually only have 2 hands. Btw, if you found a way to add number 3, do a video on it.
In my opinion this channel is a real virus ;) This one inspired me to use arch and DWM as my daily driver and I wouldn't come back. Thank you for all that you do!
I believe his body responded this way when he was using emacs, now He flexes his new form on us mortals, go challenge him in epic VIm battle and perish (idk. Like VIm golf maybe).
Can anybody help me where to find a list of command like "t" in g/import/t$ "takes" and "m" for move in vim? since i cannot locate them on any available cheatsheet online and need to specifically look fort them in :help. P.S: i originally the t /m are only meant for findiing Till and Mark till today lol
Top Video, thank you. Insert 2 Lines alternative: :g/./norm 2o or :g/./norm A (Just press ctrl-v and enter, do not type this characters ;-) - displayed was :g/./norm A^M^M ) For every line with min. 1 Character (.) run the normal command 2o (insert 2 lines) No further lines are inserted under empty lines. Use ^ instead of . to insert 2 lines under empty lines. Use ^$ instead of . to insert 2 lines ONLY for empty lines. (^...$ only for line with exact 3 Charactes, ^... for lines with min. 3 Characters; its just regex) Use `norm 2O` to insert the lines above or `norm yyp` to copy every line with content.
I like how there are youtubers that are suffering from "creativity crisis" running out of ideas for new videos, and then there are linux youtubers getting infinite inspiration from manuals.
10/10 content
It's more of an unmined resource, like gold on the moon.
Well that thumbnail just gave me a new idea on how to spell out vim when they ask me if I prefer vim or emacs
lol, looks like 6 4 14 to me :p
@ I mean. You could always summon the demons of azerath.
Pretty sure there's an Emacs package for doing that, actually
@ you can just use your...
This thumbnail is the greatest thing I’ve ever seen. DT is the best Linux channel on UA-cam, period. These videos are well scripted and easy to follow. I have learned more from DT than any other single source.
Thank you for the great content.
I dont think he scripts his vids
"Who you with fool? What hood you from?" *Throws up every possible gang sign simultaneously
I like to use the normal command with the global command. One example I use when I install Arch that many of you will probably find useful is going into /etc/pacman.d/mirrorlist and doing:
:g/## United States/normal VjdGp
That moves all of the mirrors from the US to the bottom of the document so I can just do:
gg6jV/United Stateskd
And now my mirror list is all from the US.
But a nice thing to know is that you can combine it with macros. Basically, you go to a line you would want to affect, start recording a macro only on that line, stop recording the macro, then call the macro in the global command prompt. This is handy when you're doing a complex macro on a ton of lines because just doing the global command can be confusing since you don't visually see what's happening. And making the macro in a way that it does the stuff, goes to the next instance, then redoes it can be extremely slow.
For an extremely simplified example, if you want to put the word "foo" as the second to last word of any line that says "bar" already, you can do:
qw$Bifoo q
:g/bar/normal @w
And if you have a long macro and/or a lot of lines to do it on, it's much faster than recording the same macro except making it go to the next instance as well, and then doing 100@w or something like that.
And finally, if you need to use a special character/key in the global call, like you need to emulate the person pressing the enter button, just press ctrl+v and then the button.
One of the most powerful global command applications in my opinion is in combination with the `normal` command. It lets you execute a sequence of keypresses as if they were typed from normal mode.
This way you can have something like :g/^\s*int/normal ^cwlong to replace every line starting with int to start with long instead. Just something I came up with in the moment but the possibilities are endless. You can kind of think of it as a multiple cursor implementation of sublime text in vim.
You would use substitute for this case
Or apply a macro with :g/patter/normal @q
:.write
command is actually pretty useful when you are editing a script and want to test one of the line.
Indeed, you can redirect the output of the write command to the stdin of any other process.
:.write !bash
would execute the particular line you are on and see the ouput from your shell (here I choose bash but obviously could be any shell)
Good tip!
Although you don't need 'write' for that just
:.!bash
will do the same thing
An interesting addition to the :g command not mentioned is that it can also take a range itself, limiting its "global" scope to whatever section of the file you want.
So to reverse only lines 10-20 in your file:
:10,20g/^/ m9
Note that you move the matched lines to one above the point you want the insertion to start at.
You can also nest multiple global commands.
One slightly tricky gotcha with :g is that it always needs to include a match string. This means that to use :s with it instead of %, you would need:
g/^/ s/foo/bar/
Combine all the multiple ranges and matches available and you can target quite complex and powerful selections.
Dude, I have no doubt you run the best Linux channel on UA-cam.
Uat
This is so valuable to me, it sticks in my brain so much better when someone’s explaining it conversationally
"Once you discover Vim, it's a way of life. I could never use another text editor." - Doom Emacs User
I knew about running shell commands with :! and I knew about using :read command to paste file contents. But I didn't think of using :read ! to paste the shell output. Very useful!
Thanks for a very informative video, Derek! This helps to nudge my vim-fu ahead another baby step. Once thing I discovered on my own was doing a Visual or Visual Line and hitting colon, which puts the selected range on the command line, ready for a substitution, etc. Cheers.
00:36 command mode intro
00:58 run shell commands from vim
01:37 read a shell command's output and put it to the current line, e.g. :read !date
02:41 :$read !date
Never seen the power of vim so well showcased anywhere before like in this video. Excellent job, dt!
Thank you very much!
Wow, this was a really good vim tutorial! Most of the things you showed had real practical uses, which is great, because I can already imagine myself using them.
Came here for the featured pic. NOt disappointed !
You a very talented bald bro .
Interesting... In most cases I find it easier to mark ranges with visual line mode. You can then type a colon which brings you into command mode with your range already specified, and you can add what ever you want, like substitutions, write to a new file, and so on
Excellent job with separating your brand from the static. I love the video and the thumbnail.
Very useful video, thanks DT!
Thumbnails for the past few vids have been absolute fire
thumbnail had me rollin!
6:20 That was new info to me. Thank you! (I've been using vim since 1995.)
Uh... this video blew my mind. So much great stuff I did not know about!
Quick note about the :s/(pattern)/
Command the (pattern) is a regular expression which is a whole other beast
Very nice job. Interesting topic!
another amazing video! thanks DT!
btw I use xmonad!
Nice! Always fun to learn new vim commands. Only thing missing was the confirmation option for global search and replace.
Thank you! Helped me understand command mode better \o/
Very Helpfull!
This is so whack today I used the
:%s /pattern/replace/g command today in some C++ programming and I googled "What does g command do in vim" and it all didn't make sense to me, your video shows me not only what g does but also what % does and so much more. Funny how sometimes you don't even got to search for what you were trying to figure out earlier and it pops in your reccomended when you are subbed to some good channels. 🙌
9:16 I find using :%s/^/
to insert a blank line before each line easier than your g command
That last trick straight up G. 🤣
Gettin' all gangsta' here in da' dtube bruh!
I have never enjoyed receiving the fanger so much🤣
200IQ thumbnail sir
Thank you DT!
I thought I understood how powerful vim was. I had no idea!
Hey DT, could you make a video installing Arch, a window manager and ricing it from scratch? Nothing really extreme, just basic stuff. Cheers from Brazil!
Why?
Love this. I have just been getting into VIM and learning new and more useful commands and bam I run into your video showing me even some more to add to my list. Awesome stuff. btw - VIFM is another great command line file browser (like ranger) related to VI so maybe you could talk more on that too.
Hey DT, have you heard of Kakoune? I learned about it in the comments of one of your videos. It’s reminiscent of Vim but tries to stick to the Unix philosophy better. In particular, it gives visual feedback to commands and relies heavily on what it calls “selections”.
Great video, as always!
I'm keeping that thumbnail in my image collection forever.
im intrested in seeing your collection
excelent man!, i moved from emacs to Vim recently and i find it pretty well than emacs!!,,.. please do a lot of video like these.. Thanks
Liked for reversing lines of a document. :g/^/m0
...and I thought I knew enough but this is superb, thanks :D
I wrote this too fast.. holy crap what you can do in there!!
Can I move to your place for like 3-5 months or so for some real cram of Linux :P
"I could never use another text editor" DT.
I think you should edit the thumbnail with even more signs and gestures with arms coming from every direction surrounding you
Dude, what happened to your intro ditty? I really liked that.
Like for the thumbnail.
I bet you were great at N64 games
Dt bought fully functional arm device.
but can you use g to move stuff to a different file (say move all source code in a latex document to an external file you can then import, instead of being put in verbatim)
Crikey. Yesterday, I found myself having to reverse a file for the first time in my life. Googled and found a sed oneliner. Happy.
Today, this pops up first in my UA-cam recommendations! Now paranoid...
G is so powerful😄
when using mode() to display in my StatusLine, why does it never show 'c' for COMMAND, it remains as NORMAL and the mode() function does not return 'c'. For insert mode it changes to 'I' but never changes to 'c' when entering into COMMAND like yours does. Am I missing something?
Quick question Mr DT or anyone else that wants to answer.
I've just bought a new ASUS laptop that has a 4k screen.
Does Ubuntu or any of the flavours of Ubuntu 20.04 (MATE etc) work ok in 4k?
Hey, Can you please make a video about how we can have follow-mode in Emacs inside vim/nvim? There are some tutorials about :set cursorbind and :set scrollbind in vim, but they don't do the follow-mode job. thank you!
Ha! I had to read others comments to understand what's going on in the thumbnail.
Could you give us your top lightweight distros?
:g or g! /pattern/command is crazy
The thumbnail is a subtle gesture to eMac users
Get your Vim range, global and substitute black-belt with WAZ -- github.com/dahu/vim_waz_ere
btw : in youtube speeds up the video. :D
:t and :m were nice new tricks I learnt :D
You quarantined by a nuclear reactor? Cause in my neck of the woods, ppl usually only have 2 hands. Btw, if you found a way to add number 3, do a video on it.
In my opinion this channel is a real virus ;) This one inspired me to use arch and DWM as my daily driver and I wouldn't come back. Thank you for all that you do!
no one? ok, i'll say it then... Vim Diesel! :D
Now you have three hands dt?
I believe his body responded this way when he was using emacs, now He flexes his new form on us mortals, go challenge him in epic VIm battle and perish (idk. Like VIm golf maybe).
rochr4 nah he was probably playing N64 before he made this video.
Can anybody help me where to find a list of command like "t" in g/import/t$ "takes" and "m" for move in vim? since i cannot locate them on any available cheatsheet online and need to specifically look fort them in :help. P.S: i originally the t /m are only meant for findiing Till and Mark till today lol
What distro is this?
Oil_boi_ He usually runs Arcolinux.
Gangster.
Did DT just showed us his baby arm?
Thumbnail getting video flagged in 3 2..
Why you have change your microphone every single video?
Not only did you spell out vim, but it's also 213.
looks like 6 4 14 to me :p
hey can anyone help me i am not able to join distrotube riot becaue of nick reggeed something
First like😁
1:59 read? no imma gonna stick with $ is easier
Second
That thumbnail is cringe.
FiRsT
YeA, dAwG!
Top Video, thank you.
Insert 2 Lines alternative:
:g/./norm 2o
or
:g/./norm A
(Just press ctrl-v and enter, do not type this characters ;-) - displayed was :g/./norm A^M^M )
For every line with min. 1 Character (.) run the normal command 2o (insert 2 lines)
No further lines are inserted under empty lines.
Use ^ instead of . to insert 2 lines under empty lines.
Use ^$ instead of . to insert 2 lines ONLY for empty lines.
(^...$ only for line with exact 3 Charactes, ^... for lines with min. 3 Characters; its just regex)
Use `norm 2O` to insert the lines above or `norm yyp` to copy every line with content.