Тёмный

Vim Tips You Probably Never Heard of 

Luke Smith
Подписаться 211 тыс.
Просмотров 120 тыс.
50% 1

Here are some simple but useful vim commands that many people will not know of. They have to do with line movement, automatic capitalization, moving from file to file and testing substitutions on all lines.
The theme here is that they all begin with 'g' which is a unique key because it is really only used as a prefix for even more one-off commands.
My website: lukesmith.xyz
Please donate: donate.lukesmi...
Get all my videos off RU-vid: videos.lukesmi...
or Odysee: odysee.com/$/i...
BTC: bc1qw5w6pxsk3aj324tmqrhhpmpfprxcfxe6qhetuv
XMR: 48jewbtxe4jU3MnzJFjTs3gVFWh2nRrAMWdUuUd7Ubo375LL4SjLTnMRKBrXburvEh38QSNLrJy3EateykVCypnm6gcT9bh
OR affiliate links to things l use:
www.vultr.com/... Get a VPS and host a website or server for anything else.
www.epik.com/?... Get a cheap and reliable domain name with Epik.
brave.com/luk005 Get the Brave browser.
odysee.com/$/i... View my videos on Odysee and get a bonus for joining.
www.coinex.com... Get crypto-rich on Coinex. Get reduced exchange fees for 3 months.
www.coinbase.c... Get crypto-rich on Coinbase. We both get $10 in Bitcoin when you buy or sell $100 in cryptocurrencies.

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

 

4 окт 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 332   
@fawzanfawzi9993
@fawzanfawzi9993 3 года назад
Quick rundown: 0:49 gj and gk : Move cursor up and down to wrapped part of a line as if it is a different line. 2:12 g0 and g$ : Same as previous but move cursor to the first and last letter of a wrapped line. 3:32 gq : Turn a long line into multiple lines. 4:55 gu and gU : Uncapitalize and capitalize words/lines. 6:00 ~ and g~ : Switch capitalization of a letter. 7:02 gf : Open highlighted text as file. 8:02 gv : Reselecting previous selected text. 8:37 gJ : Conjoining lines without leaving spaces. 10:03 g& : Rerun substitute command for all lines.
@dxrbkn5145
@dxrbkn5145 3 года назад
Does gq affect latex documents? Im used to write my paragraphs on a single line
@yochem9294
@yochem9294 3 года назад
@@dxrbkn5145 Yes sure you can just use gq on that
@dxrbkn5145
@dxrbkn5145 3 года назад
@@yochem9294 thanks!
@devstefancho
@devstefancho 3 года назад
:help g for getting more info
@bradywb98
@bradywb98 3 года назад
Thanks for saving my time
@alkeryn1700
@alkeryn1700 3 года назад
my favorite is "cgn" you can search a text or patern with "/" then do "cgn" to change it to something different. then typing "cgn" again will jump to the next occurence and change it. you can then type "." to repeat as much as you want. or do something like "3." or "3cgn".
@peacemekka
@peacemekka 3 года назад
damn. Its like a book of spells lol. You just keep finding more and more crazy stuff that saves a helluva time.
@jimxu1963
@jimxu1963 3 года назад
You are disclosing dark magic... That's dangerous...
@iLiokardo
@iLiokardo 3 года назад
Don't you just do simple find replace?
@mamrezo722
@mamrezo722 2 года назад
/somethingqacgnsomethingelseq5@a That's just ....
@camilotello3296
@camilotello3296 2 года назад
Woahhh dude, I really liked this one. Thank you c:
@mrsansiverius2083
@mrsansiverius2083 3 года назад
This feels like pre-content creator Era of Luke. Back when he used Void and Parabola and had no facecam
@rexevan6714
@rexevan6714 3 года назад
And still not used org mode
@eolien5518
@eolien5518 2 года назад
What do you mean ?
@IlyesSem
@IlyesSem 2 года назад
An awesome one too: color0 -> color1 color0 -> color2 color0 -> color3 "v i p", to select the entire paragraph, then "g " to increment sequentially
@ocaly
@ocaly 3 месяца назад
how to do it from 0 indexing?
@enriktigasna
@enriktigasna 3 месяца назад
@@ocaly select second one down, or c-x after doing g
@brunobelotticom
@brunobelotticom 3 года назад
Another g command I found invaluable is gx, which opens any URL under the cursor in the browser (technically it "execute application for file name", but I use it pretty much only for links). Anyway, thank you for this video: I knew most of them, but the "Conjoining lines" is going to save me SO MUCH TIME. Thanks!
@hnasr
@hnasr 3 года назад
That multi-line word-wrap tip is amazing! sweet tips! thanks, Luke
@jeremydoerksen5988
@jeremydoerksen5988 3 года назад
Right?
@victorgabr
@victorgabr 3 года назад
Sweet gqG 😆 It just saved me a lot time
@carlislenightingale8853
@carlislenightingale8853 3 года назад
so basically "g" stands for god mode ?
@raushonmunni2633
@raushonmunni2633 3 года назад
hello hussein
@JohnDoe_69_420
@JohnDoe_69_420 3 года назад
8:28 bless you
@Theosibo
@Theosibo 8 месяцев назад
Great video, even a couple years after the fact. Started unlocking the powah of vim motions about 6 weeks ago and videos like this that heavily cover things the :Tutorial only lightly touch on are a tremendous help. Most of us already understand gg (top), G (bottom) 173G (goto line 173) but the rest of this 'g stuff' requires we dig DEEP into the user manual (which I actually started doing last night) to learn. I make it a point every morning to start with the :Tutorial, speedrun through it and then creep into user or reference manuals for deep understanding for 30m before I get started with my daily work and EVERY time I do this exercise another powerful tool is stamped in my forever memory and makes my workflow that much easier. What a powerful tool. Thanks for the info!
@mackenzieowens161
@mackenzieowens161 3 года назад
is there a vimtutor that teaches me how to get a gf?
@electrolyteorb
@electrolyteorb 5 месяцев назад
Vim community believes in keeping things realistic. So, no.
@janscholz9602
@janscholz9602 4 месяца назад
I just found out that vim was invented on the Amiga, maybe you can get one of these?
@mskiptr
@mskiptr 3 года назад
I actually found out that formatting text like this is way more convenient than hard-wrapping lines at a certain offset. This gives you nice diffs later on, but also is just more readable - you can quickly skim through a block of text and easily notice actually relevant words.
@guidomarrone9562
@guidomarrone9562 Год назад
I read this as a poem.
@mskiptr
@mskiptr Год назад
@@guidomarrone9562 It works lol Let's call it _poetic formatting_ or something
@CamaradaArdi
@CamaradaArdi Год назад
It's really annoying to read though
@tokiomutex4148
@tokiomutex4148 3 года назад
I've been using vim for a couple of years and I feel like I've barely scratched the surface. Nice video btw!
@migtrewornan8085
@migtrewornan8085 3 года назад
I've been using vim for 20 years and I didn't know gJ.
@arcadesoft294
@arcadesoft294 3 года назад
Well you don't need to go deep, most people just use a subset of commands anyways.
@nonconsensualopinion
@nonconsensualopinion 3 года назад
@@arcadesoft294 The problem is sometimes you need to go deep to find that small subset.
@angusmacgyver
@angusmacgyver 3 года назад
Thank you Vim Diesel.
@akim5227
@akim5227 3 года назад
Let's gooo, thank you for good content, Luke
@sunset-inn
@sunset-inn 3 года назад
Luke is a content creator after all.
@desktorp
@desktorp 3 года назад
gq isn't a keybinding-- it's the magazine whose cover you'll be featured on with that fancy shirt
@carstenschlegel6975
@carstenschlegel6975 6 месяцев назад
g Adds Numbers in sequence. Write: Line 0 Yank this (yy) and copy it 10 times (10p) Then mark the last 10 lines (V10j) Press g (Control A) You have Line 0 Line 1 Line 2 ... This works for the FIRST Number that VIM found in each line. data[0] = "Number 0"; data[0] = "Number 1"; data[0] = "Number 2"; data[0] = "Number 3"; ... where renumbered to data[0] = "Number 0"; data[1] = "Number 1"; data[2] = "Number 2"; data[3] = "Number 3"; ... The Number in the String (Number 0...) was unchanged.
@johanferozco
@johanferozco 3 года назад
Thank you very much, Luke. I ALWAYS enjoy you talk about Vim. It's is because of you that I'm trying to use it more often and it's always good to learn new things about it.
@a_maxed_out_handle_of_30_chars
@a_maxed_out_handle_of_30_chars 3 года назад
Finally a video which I know almost 90% :)
@alternateperson6600
@alternateperson6600 3 года назад
"et ut illi, qui converti non possunt, non minus per opera sapientiae quam per laborem bellicum reprimantur" seems like the perennial approach to wisdom. Thanks for the book (and author) suggestion by the way; adding it to my own personal library.
@teacon7
@teacon7 3 года назад
A hardened heart isn't going to budge for anything. "Having ears, they do not hear..." Better to ask, I suppose, What it is that causes the "converti."
@jitessh
@jitessh 3 года назад
After hours of ranting in woods, Vim Diesel is back on his uwu linux.
@kirkgraham6469
@kirkgraham6469 3 года назад
I've used vi (and variations) since 1985 and learned some new things today. Thanks! :)
@tunina6421
@tunina6421 3 года назад
Where I work, there are a lot of monitors that are vertical and single line wrapping is quite common in files that I work with. This is quite helpful.
@himanshushukla6451
@himanshushukla6451 3 года назад
Finally he posts something useful!
@mamadkhan6708
@mamadkhan6708 2 года назад
I'm new to Vim , and it's been two weeks that I've been using Vim as my main code editor . It's just mind blowing and awesome! By combining different commands u can do crazy things much faster. It's just great . I LOVE VIM!
@alanbarnett328
@alanbarnett328 2 года назад
Feels pretty slick watching this and the only thing you learned was g&. Love me some g commands. Literally at the beginning when he said "one key on the keyboard that is unique in vim" I said with him 'g'. Feelsgoodman
@s.espinoza1167
@s.espinoza1167 2 года назад
thank you a lot for this video, Luke. As a programmer, I'm always trying to learn all the tricks and tweaks that I can to make my development process faster, and your tips helped me with that. Cheers!
@KbIPbIL0
@KbIPbIL0 3 года назад
blew my mind with gq, man, thanks!
@VulcanOnWheels
@VulcanOnWheels 3 года назад
8:27 Bless you! Some of what you explain in this video is actually included in vimtutor. I did learn something new though.
@prajwalbasnet4461
@prajwalbasnet4461 2 года назад
I subscribed! Thank you for the awesome tips.
@sanchopanza9907
@sanchopanza9907 3 года назад
Thank you Luke, I needed this to navigate large one line json files pulled from an API.
@victoralcorta
@victoralcorta 10 месяцев назад
amazing, it's incredible how you never stop learning vim things haha here you got another one with substitution that is really cool for me when you got a bunch of text selected you can press : and make a substitution like you did with s/text/replace and that will apply only to that block of text selected, also you can do it like with the number lines :1,5s/text/replace but this is very much practical, no need to see line numbers Cheers, nice video!
@vlmath314
@vlmath314 3 года назад
great video. regarding the gq command, you will have issues storing text formatted this way if you are using git to track the changes in the document. it's highly recommended to save one sentence per line, one line per sentence; the git diff will be way easier to understand as opposed to the situation where a sentence is split between multiple lines (diff will show a difference for the current sentence and all the words that append to be at the end and start of the lines in that paragraph, even if you don’t change anything in these sentences).
@blanky_nap
@blanky_nap 20 дней назад
Great video! I am using vim everyday for coding. And very often all commands with g modifier are helpful indeed
@none-cc7im
@none-cc7im 3 года назад
>g& WOOW. I learned a new world.
@andreasproteus1465
@andreasproteus1465 3 года назад
Did he hit your g-spot?
@TheTrojan665
@TheTrojan665 3 года назад
ty for doing the needful. i've been working with markdown and the gj tip is a lifesaver.
@gavinridley5727
@gavinridley5727 3 года назад
I actually hit "0" to go to the beginning of the video... and it frickin works!
@zackinator1439
@zackinator1439 3 года назад
Ha ha, reminds me of the time I was using Windows for the first time in a while after using LARBS and discovered some of the shortcuts I kept instinctively pressing actually did things. Super+number opens that numbered item on the taskbar for instance. And since I was so used to pressing super all the time, when I tried to alt-tab I pressed super by accident and realized super-tab is like a better alt-tab.
@octopusonfire100
@octopusonfire100 10 месяцев назад
I miss this kind of content. It is what got me into Vim
@GityaLIVEdnb
@GityaLIVEdnb 3 года назад
VIM Diesel is back !
@arijitkumarhaldar3197
@arijitkumarhaldar3197 3 года назад
Alternative title : Discovering the secrets of g- with Luke Smith.
@iurysza
@iurysza 3 года назад
I've just learned about gj and gk in the first two minutes. This is enough content for me to assimilate right now. Thanks!
@danielmwale9959
@danielmwale9959 3 года назад
Yeah, the power of learning is to assimilate in smaller chunks.
@wafflelite
@wafflelite 3 года назад
I subscribed to this channel for the thumbnails
@liftlinux9421
@liftlinux9421 3 года назад
He almost banned because of this
@zneix
@zneix 3 года назад
Very good idea for a video, I've learned like 3/4 of all those shortcuts. Thanks Luke!
@testertech
@testertech 3 года назад
Thanks a lot, very useful beyond the basics of VIM! Will surely try to use these keybindings to unleash more of the Power of VIM in my workflow.
@archuser7607
@archuser7607 3 года назад
So good to see you making some educational videos after so many days
@timothyvandyke9511
@timothyvandyke9511 3 года назад
Also, if Vim is too scary for someone to try just jumping in (especially if you need to stay productive for work or something) the VS Code (and Visual Studio) Vim Extension(s) are fantastic. You still keep 100% of the editor commands the same if you're in insert mode too so you can have "training wheels" if you don't have time to look up "how to do x in vim" all the time. It lets you pick a piece or two to learn at a time. I love them
@oscarlove4394
@oscarlove4394 2 года назад
as an additional anti-frustration feature, you can toggle the extension on/off with a custom hotkey, I have mine bound to ctrl+d. so if vim feels like its getting in the way or you don't know how to do something in fim, like find and replace or whatever you can just quickly toggle it off and back on again.
@jongeduard
@jongeduard Год назад
As a developer using VS at work especially, while also being a Linux enthousiast at home, I am currently also on the Vim path and I started using the VsVim extension. It's really great and also respects your existing key bindings a lot, and you can (and probly want to) configure much around that behaviour, at least a real need for me, because I already customized a lot of things in other ways and certain things just need more time to change, even though the whole thing looks pretty much worth it. I yet have to install the one for VSCode too, but I believe that one may be great as well.
@console.logged
@console.logged 9 месяцев назад
My problem with that is I get too comfortable. I’m pretty good with VS Code shortcuts, which means it’s almost always slower for me to do it the Vim way. I only really learned Vim motions when I had to use Xcode or ssh into a Pi or something
@KurtSchwind
@KurtSchwind 3 года назад
Well done tips vid. I haven't made good use of the 'g' modifier before. If you want a concrete example of joining lines and losing spaces. I recently had an out of control PATH variable. So I saved it to a file, split lines on `;`, got rid of dupes and changed the order. Then I had to 'restore' the line and I did the Jx thing a few dozen times (yes, I could have done a macro), but had I known about `gJ` it would have made my life easier.
@pawekoaczynski4505
@pawekoaczynski4505 3 года назад
Similar to gV, gi puts you where the cursor was the last time you were in insert mode
@Alec_Reaper
@Alec_Reaper 3 года назад
HOW DO I EXIT VIM 👁️👄👁️
@PASRC
@PASRC 3 года назад
Why would you exit vim?
@Alec_Reaper
@Alec_Reaper 3 года назад
@@PASRC I need to do my taxes 👁️👄👁️
@beavatatlan
@beavatatlan 3 года назад
Unplug your computer
@PASRC
@PASRC 3 года назад
@@Alec_Reaper do your taxes in vim
@arkayenjay
@arkayenjay 3 года назад
:! poweroff
@GonzaloOviedoLambert
@GonzaloOviedoLambert 3 года назад
As Always, you are a master!, thank you for all your vim teaching.
@Jagi125
@Jagi125 3 года назад
Should I feel bad for using Vim since quite a few years and not knowing more than half of them?
@hoshiya4522
@hoshiya4522 3 года назад
YESS I NEEDED THIS
@Yeso00
@Yeso00 3 года назад
YYYEEEEEESSSSSS
@catwhisperer911
@catwhisperer911 Год назад
When Bram wrote Vim he created a lasting legacy to his name. May he RIP.
@Xhisorz1
@Xhisorz1 3 года назад
gv is great! Didn't know about that one. Thanks!
@ravidesai9556
@ravidesai9556 Год назад
This was very helpful. Thank you.
@teacon7
@teacon7 3 года назад
good vid. I love it. How on earth do i figure out how to print in linux? It won't support my workplace's printer, which I need to use to do my job.
@linuxmanju
@linuxmanju Год назад
Wooow, the best video i have seen till date. Thanks and subbed.
@leoliu2079
@leoliu2079 3 года назад
Luke is the only one making useful Linux videos
@matj12
@matj12 3 года назад
I prefer when each paragraph is on one line, because, then, the text can be wrapped at different widths as it's needed. A downside of putting line breaks after a certain line width is that the text looks ugly when it's displayed with a proportional font. A Vim plugin that softly wraps lines at a certain width and draws the text at the centre is goyo.vim.
@dixztube
@dixztube 6 месяцев назад
Whoa you’re the dude in one of Kenny’s hilarious video posters lol. Hahahahahaha that’s great - came for the vim tips got a big lol
@Danscottmusic
@Danscottmusic 3 года назад
thanks for the tips g
@lelandkwong
@lelandkwong 3 года назад
luke coming through with the vim fu as always
@naughtiusmaximus789
@naughtiusmaximus789 3 года назад
8:27 uh oh.. Luke Smith contracted the c-word
@GauthamReddy
@GauthamReddy Год назад
Some great useful tips for Vim users. Thank you.
@python360
@python360 3 года назад
Great tips man. zoomers and soydevs be like 'that's so much to learn, I only know how to swipe left' Also, teaching me shift+zz was so valuable way back - :wq is gone forever.
@cebruthius
@cebruthius 3 года назад
Ctrl+Z does something very different.
@johnpaulhumphrey2981
@johnpaulhumphrey2981 2 года назад
I have been using vim for several years now, and I didn't know about gj and gk!
@labrat324
@labrat324 3 года назад
Luke dropping some heaters!!
@WilliamMelton617
@WilliamMelton617 3 года назад
gj and gk will forever change how I use vim. Thank you sir 😭
@majam1n
@majam1n 3 года назад
Missed thumbnail opportunity of Vim Diesel on the cover of gq.
@MaxCoplan
@MaxCoplan 2 года назад
Great video. This guy's a real G
@leftaroundabout
@leftaroundabout 3 года назад
I don't subscribe to gq. I used to always format my lines (of e.g. LaTeX) into 80 char limit myself, but at some point I realised it's just unnecessary work, a document with long lines can actually be navigated _faster_ (and just as accurately, thanks to gj / gk), and additions of a few words won't show up as multiple lines changed in the git diffs anymore. It's still a good idea to keep _source code_ lines below 90 chars, and definitely break line after every other sentence or so. But there's not point sticking to a fixed 80 chars, when text editors can just display long lines with line-wrap.
@archuser
@archuser 3 года назад
Bless you
@linuxinside6188
@linuxinside6188 3 года назад
Vim diesel is bacc
@camilotello3296
@camilotello3296 2 года назад
Man, I loved this video, insightful!
@haesklar3635
@haesklar3635 3 года назад
you saved my life thanks for the cool info
@gurdeepgss
@gurdeepgss 3 года назад
^ takes you to most recent buffer and not file as luke said
@atimholt
@atimholt 3 года назад
Iʼve remapped `Q` to `q:`. The meaning stays similar, and `q:` is ridiculously nice and useful (especially compared to `Q`, lol).
@Jango1989
@Jango1989 3 года назад
1:39 in and already my mind is blown. Thanks for this! Very useful!
@deeznutz2322
@deeznutz2322 3 года назад
Should have sneezed at the camera to scare the normies.
@kinzoku777
@kinzoku777 2 года назад
Luke Smith out here like a G
@badpotato
@badpotato 3 года назад
really useful commands
@vterpko
@vterpko 3 года назад
Nice video. Thanks Luke!
@jesterflint9404
@jesterflint9404 3 года назад
Not the content we deserved, but the content we needed.
@kriskropd
@kriskropd 3 года назад
It's amazing how long you can go about using Vim and not bother to learn all the keybinds this thing has...
@torphedo6286
@torphedo6286 10 месяцев назад
Wow, thanks for letting me know about gq, g0, and g$. I use Vim bindings in Obsidian to jump to the end of my notes quickly, and I found it really annoying to navigate long bullet points or paragraphs (especially with Obsidian's narrow default line wrapping). This will help a lot with my note-taking.
@peteryates308
@peteryates308 3 года назад
The one disadvantage of splitting up your lines of prose is that when you rephrase it your version control history can be more difficult to read, especially if you need to rerun gq across your paragraph.
@miladini1
@miladini1 3 года назад
Thank you, Luke!!
@timothyvandyke9511
@timothyvandyke9511 3 года назад
I accidentally found the J command. I just assumed it meant "modify the down command" instead of capital J for "join". That's one of my favorite commands
@lloydbond13
@lloydbond13 Год назад
Damn. That was really useful.
@Zen-lz1hc
@Zen-lz1hc 2 года назад
Really cool video Thanks Man!
@obszczymucha1337
@obszczymucha1337 Год назад
8:26 Bless you!
@utvikler-no
@utvikler-no Год назад
Awesome tutorial ❤
@buntun3670
@buntun3670 Год назад
this stuff makes me look like a genius
@edvonrattlehead2135
@edvonrattlehead2135 3 года назад
he did it, vim diesel teached more vim, finally!
@zestynotions
@zestynotions 3 года назад
pretty darn useful
@canmetan670
@canmetan670 Год назад
Learning gJ was useful here. I don't think I'll ever need the rest.
@snipzmattio5887
@snipzmattio5887 3 года назад
Thanks, really usefull!
@fernandomota7193
@fernandomota7193 3 года назад
0:59 I'm going up and down side to side like a roller coaster.
@besheraladdam9325
@besheraladdam9325 3 года назад
Very useful ty.
@GavinFreeborn
@GavinFreeborn 3 года назад
Figured it is worth mentioning that gq can do much more than you mentioned doing a quick `:help gq` will give you a quick explanation. You can basically use it as a code formatted that is much more powerful than `g=`. There is also a video on code formatting in vim that covers this much better than I ever could in a comment.
@beron_the_colossus
@beron_the_colossus 3 года назад
To get the `g~` functionality by default you can `set tildeop`
@zacharystreeter1965
@zacharystreeter1965 3 года назад
g; is one I use often
@balmar3
@balmar3 3 года назад
Exactly. He forgot the two most important ones, g; and g, .
Далее
Vim Tips I Wish I Knew Earlier
23:00
Просмотров 68 тыс.
A Vid in which Vim Saves Me Hours & Hundreds of Clicks
10:23
TRENDNI BOMBASI💣🔥 LADA
00:28
Просмотров 781 тыс.
Women’s Celebrations + Men’s 😮‍💨
00:20
Просмотров 4,5 млн
Mastering the Vim Language
36:20
Просмотров 613 тыс.
Vim Tips And Tricks Some Of My Favorite Vim Commands
17:05
I tried 10 code editors
10:28
Просмотров 3 млн
10 Advanced Vim Features (You Probably Didn't Know)
21:47
This VIM trick BLEW MY MIND
6:37
Просмотров 54 тыс.
AI Will Make (Has Made) the Internet Mediocre...
12:14
My Favorite Vim Tricks
14:39
Просмотров 182 тыс.