30 Vim commands you NEED TO KNOW (in just 10 minutes)

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 พ.ย. 2024

ความคิดเห็น • 205

  • @typecraft_dev
    @typecraft_dev  7 หลายเดือนก่อน +5

    To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/typecraft . You’ll also get 20% off an annual premium subscription.

  • @typecraft_dev
    @typecraft_dev  7 หลายเดือนก่อน +84

    🚨 I misspoke!! 🚨
    Typically with Vim videos, I tend to do them from top-of-my-head knowledge. For some reason, I always think of the "substitute" command as "sed".
    "s" is substitute, not "sed" sorry for any confusion, hope you like the video!!

    • @wh7988
      @wh7988 7 หลายเดือนก่อน +2

      thank u daddy, took the vim pill because of u

    • @RomanLi-y9c
      @RomanLi-y9c 7 หลายเดือนก่อน +1

      awesome video, thank you for the macro ;) all devs should love it

    • @RobertGottlieb
      @RobertGottlieb 7 หลายเดือนก่อน +1

      Another way I've seen this done is :0,$s/find/replace/

  • @WhiteRickRoss
    @WhiteRickRoss 7 หลายเดือนก่อน +79

    v + i + w + y (to copy the selected word) can be done with y + i + w (yank inside word)

    • @andrewbach42
      @andrewbach42 6 หลายเดือนก่อน +7

      Or if ur at the beggining of a word just yw

  • @23luski23
    @23luski23 7 หลายเดือนก่อน +225

    /g in sed command means global in line, not in entire file. So without /g replacement will be done for the first occurrence in each line where we have matching

    • @zerdofish9989
      @zerdofish9989 7 หลายเดือนก่อน +24

      Indeed! What makes it global is the %

    • @eivindsulen8516
      @eivindsulen8516 7 หลายเดือนก่อน

      @@zerdofish9989 when i first learned this i realized you can select lines in visual mode and run substitute on just this range of lines. :'

    • @matiasbpg
      @matiasbpg 7 หลายเดือนก่อน +17

      To add to the %, this is really a range, that means the whole buffer. Most commands accepts a range at the beginning and there are a few shortcuts for ranges:
      :x,y. from lines x to y
      : .,y '.' means the current line so it's current line to y
      :'

    • @silak33
      @silak33 6 หลายเดือนก่อน

      Thought the exact same thing XD

    • @zerdofish9989
      @zerdofish9989 6 หลายเดือนก่อน +1

      Thsnks! I didn't know this.

  • @ivanheffner2587
    @ivanheffner2587 7 หลายเดือนก่อน +74

    Did you know you can append to a named register? “xY will yank the current line into register x. “XY will append the current line to register x. This lets you build up a register to paste later. For example: you want to grab a couple lines of code from several locations and paste them into a new function, you can gather them all into that register and then do one paste when you have them assembled.
    Also, because a macro is just executing a register, you can edit a macro by pasting the contents of the register, modify it, then yank the new macro back into the register ready to run the modified macro.
    One last item: a macro can call another macro or even itself. Writing recursive macros to update thousands of lines can be quite satisfying, but is most useful if making a regex substitution is just too difficult or not quite fully repeatable.

    • @marcuswest4572
      @marcuswest4572 7 หลายเดือนก่อน +1

      Sounds like a video in itself

    • @CoClock
      @CoClock 7 หลายเดือนก่อน +1

      Macros are executing registers!!!!?!

    • @ivanheffner2587
      @ivanheffner2587 7 หลายเดือนก่อน +3

      @@CoClock 🤯 right? Try it yourself.
      Record macro x
      qxcawfooq
      Paste the contents of register x
      “xp

    • @silak33
      @silak33 6 หลายเดือนก่อน

      On the subject of upper case registers.
      If you record to an upper case register you will append to what is in that register rather than replace it. That is very useful if you forget something :)

    • @eugeneponomarov7429
      @eugeneponomarov7429 6 หลายเดือนก่อน

      Omg, this is super powerful!

  • @priyanshukatuwal
    @priyanshukatuwal 7 หลายเดือนก่อน +13

    I am a beginner, I hated VIM at first and I told myself I would never touch it again. But I kept learning things little by little. Your channel helped me a lot, it has made me fall in love with VIM. I am also following your playlist to learn to make my own Neovim config. Thanks nerd!

  • @mischavandenburg
    @mischavandenburg 7 หลายเดือนก่อน +9

    Hi! I’m a content creator in the same space, and I really appreciate the quality of your videos and the work it requires to create them. This video is a great guide for beginners and showcases the power of vim editing in such an effortless way, Keep up the good work!

  • @holdthat4090
    @holdthat4090 7 หลายเดือนก่อน +15

    will toggle between the current and previous buffers, you can mash it to go back and forth kinda like harpoon. Also lets you go backwards in the jump table if you wana navigate back a line or two or three etc.

    • @willernst
      @willernst 7 หลายเดือนก่อน +1

      And the pairing to travel back forward in the jump table (use "o"ut and "i"n as the mnemonic).

  • @EdygarOliveira
    @EdygarOliveira 2 หลายเดือนก่อน +8

    If you already have it already highlighted by the *, you can simply :%s//replacement/g, you don’t have to repeat what was highlighted

  • @RuanBekker
    @RuanBekker 6 หลายเดือนก่อน +2

    This was exactly what I was looking for! I've been using vim for the last 10 years, but ive always used the basics and what I have to use to get the job done. This is going to take me to the next level. Your videos are amazing, and I thank you for them!

  • @NilEoe
    @NilEoe 7 หลายเดือนก่อน +4

    %s already targets the whole file, the /g (global) replaces every occurrence of the word, not just the first of every line
    Super helpful video though! Didn’t know how to use registers, thanks a lot!

  • @amarug
    @amarug 2 หลายเดือนก่อน +2

    this was a WICKED useful vid. getting into nvim slowly and this really helped me lvl up

  • @eyayawb
    @eyayawb หลายเดือนก่อน +2

    So much value in 10 mins. Thank you, nerd!

  • @code-island
    @code-island 7 หลายเดือนก่อน +28

    bring the part 2 with more 50 commands

  • @jamesaffleck4192
    @jamesaffleck4192 7 หลายเดือนก่อน +9

    Great tips!
    With macros you can do @@ to replay last played macro.
    Also while recording a macro,.you can also replay that macro inifonitely until vim.encounters an error.
    I.e. for your example
    qah //start recording into h
    i"E", // addquotes around word, then add comma
    @h //.start replaying entire macro recursively, i.e. this will keep replaying the 'h' macro until error encountered.
    A couple more register tips.
    Add to init.vim or .vimrc
    set clipboard unnamedplus
    //Always yank/paste from system clipboard.
    One register tip:
    "_d //delete without overwriting default register
    In visual mode.ypu can do P to paste without overwriting.
    Here's a couple other honorable mentions.
    Use the global command to delete all lines containing search.
    :g/search/d
    And its inverse (delete lines not containing search)
    :!/search/d

  • @realbyte2048
    @realbyte2048 7 หลายเดือนก่อน +41

    Thanks moustache man, I needed this.

  • @PalashBackup
    @PalashBackup 7 หลายเดือนก่อน +4

    Although purists will say you only need tutor, I think these style of videos are more encouraging, especially for newbies.

  • @tenminuteamateurhour
    @tenminuteamateurhour 7 หลายเดือนก่อน +3

    Thanks, learned some new things! You can also create an autocommand to briefly highlight whatever you're yanking. Then you don't need to go into visual mode first.

  • @afzalhussain5728
    @afzalhussain5728 7 หลายเดือนก่อน +7

    Great video, as always! One quick note - ":s" stands for "substitute" in command mode.

    • @typecraft_dev
      @typecraft_dev  7 หลายเดือนก่อน +3

      ugh you're totally right! (and not the first to point this out). With vim stuff, I tend to do this from the top of my head. for some reason "s" has always been "sed" in my head :)

  • @roniqueh96
    @roniqueh96 6 หลายเดือนก่อน +1

    oh and another tip with macros that's powerful is to combine it with the norm command in visual mode. so instead of 5@a to perform the macro for the following 5 lines, I'll just make a visual selection of the lines I want to apply the macro to, hit colon then 'norm @@' to apply it on each line. similar can be done with the dot command, 'norm .' to perform the last change on every line (i remap this to g. )

  • @danks4
    @danks4 5 หลายเดือนก่อน

    I’ve been using nvim for over a year and learned multiple things from this video. Thanks so much!

  • @sebastianalfaro1887
    @sebastianalfaro1887 7 หลายเดือนก่อน +4

    Best vim learning serie in TH-cam! BTW loved your Patagonia t-shirt, cheers from Argentina

  • @kevinrineer5356
    @kevinrineer5356 5 หลายเดือนก่อน

    Thanks for the stuff about registers. Ive been heavily using vim for 3 months and hadnt come across the need for it, but i can see where it will be useful

  • @mascapt4231
    @mascapt4231 6 หลายเดือนก่อน +1

    Nice video, just one thing : Register copy commands ("+y") on the system clipboard will not work on some Linux system with wayland. You can reproduce this problem on a fresh install of fedora 40 . The reason ? -> no Wayland clipboard, you can fix it with your package manager in your linux distro , (Red Hat land : sudo dnf install wl-clipboard). This is pretty bad to not have that by default. It is better on any system to check clipboard support before trying to do that.

  • @abderrahmanesmimite6137
    @abderrahmanesmimite6137 3 หลายเดือนก่อน +1

    Good stuff, thank you! I’ve been waiting for a part two hoping that will cover multiline cursors tricks that I still struggle with 😊

  • @iulianesanu4237
    @iulianesanu4237 24 วันที่ผ่านมา

    Nice video ! Just one thing : you can yank into the clip board with * and + (not only *)

  • @BFedie518
    @BFedie518 5 หลายเดือนก่อน

    8:08 I didn't realize you could assign registers to each other like that. And I almost made it through the video without learning anything!
    Great video though. These are all really good to know.

  • @lileightright
    @lileightright 3 หลายเดือนก่อน +2

    damn, the amount of the helpful things in the comments is way more what is in the video ,thanks typecraft and all of the comments love my vim community

  • @SteeleMan223
    @SteeleMan223 7 หลายเดือนก่อน +1

    Just started the neovim journey this week. This was very helpful

  • @marcodem3
    @marcodem3 6 หลายเดือนก่อน

    I used vi for 35 years now and I got quick and efficient, vi under my skin. I didn't miss anything until now I know what i could have missed :-) Thanks a lot!

  • @ayeayepost
    @ayeayepost 7 หลายเดือนก่อน

    Here is a super-duper pro tip (blazingly fast and free as GPL3)
    "Use Alt key with commands in INSERT mode"
    this is the foundation of the forgotten typing art, revive it to unleash full power of the modal text editor :)

  • @submariner_42
    @submariner_42 7 หลายเดือนก่อน +7

    Impressive (both the commands and the moustache)

  • @neniugrava
    @neniugrava 7 หลายเดือนก่อน

    Also for macros, once you run @h (or whichever register you're using) you can just type @@ to run it agan.
    I usually do a ballpark guess, like 5@h, and then just hit @@ to finish the last few lines.
    Macros also work with search, so it is much more capable than just editing big contiguous sets of lines.

  • @zerdofish9989
    @zerdofish9989 7 หลายเดือนก่อน +1

    I think that :s is for substitute and not sed. Not an important detail but I think it's better to clarify so then when invoking the :help command one looks for :help substitute. Thanks for the great content!

  • @CHAP_SEC
    @CHAP_SEC 6 หลายเดือนก่อน +1

    My mind has been blow. I know vim/nvim is powerful, didn't realise just how amazing ot could be.
    Admittedly, i wont be able to remember all of this, but i will probably start using nvim :). Then slowly learn these as i need them

  • @MarceloPereira-wx7in
    @MarceloPereira-wx7in 15 วันที่ผ่านมา

    MAGNIFIC! THANKS FOR YOUR KNOWLEDGE!

  • @Fanatic17
    @Fanatic17 5 หลายเดือนก่อน

    been using vim motions and neovim for a couple of months now and this video is becoming my new bible

  • @marcuswest4572
    @marcuswest4572 7 หลายเดือนก่อน +2

    Great content.If there was a handy file, we could practice & learn simultaneously

  • @MR_Stick
    @MR_Stick 7 หลายเดือนก่อน +2

    Some of these are really a life saver, great video.

  • @pointless-video-game-videos
    @pointless-video-game-videos หลายเดือนก่อน

    One I use often and saw being used in this video, "u" in normal mode to undo the last change done in insert mode.

  • @דניאלאביב-ו6ת
    @דניאלאביב-ו6ת 7 หลายเดือนก่อน

    you can press '#' in order to select previous occurrence of a word, '#' the complementary of '*'.

  • @beastade
    @beastade 7 หลายเดือนก่อน +1

    You could replace selection with cgn command. If you repeat it with dot then it replaces the next occurrence..

  • @yodabyte
    @yodabyte 2 หลายเดือนก่อน

    To save and close, try shift ZZ. Also, you can change each matching word using sed inside vim. :1,$s;oldword;newword; and plenty of other sed commands. Old school stuff which has been around since vi in the 90s at least.

  • @zandivx
    @zandivx 6 หลายเดือนก่อน

    As in Vim/Neovim it is very important whether a letter is capital or not, it might confuse people if you display capital letters in the overlay in instances where in fact they are not capital

  • @johnathonme
    @johnathonme 5 หลายเดือนก่อน +1

    OMFG WTH!! I've been using vi then vim and now nvim for 30 years and I didn't a know a couple of these commands and the diff between the registers. Omg!! Thanks loads for the video @typecraft and love all the other comments from folks with good tips, vi just never stops giving

  • @thiagogpinto
    @thiagogpinto 7 หลายเดือนก่อน +1

    Awesome dude. I moved to NVIM for data science just by watching your content. I't been a wild ride.

  • @eddy147Tennis
    @eddy147Tennis 2 หลายเดือนก่อน

    How about search/replace throughout the whole project? Or is that better with sed on the command line?

  •  6 หลายเดือนก่อน

    After selecting something, performing any change, you can go elsewere and press 1v to repeat the same selection pattern.

  • @yesseruser
    @yesseruser หลายเดือนก่อน

    Idk when they changed/added it but in Neovim you can "+y on MacOS instead of "*y as well. (both works)

  • @srt_
    @srt_ 7 หลายเดือนก่อน +2

    that yellow light is causing camera to change focus. kind of distracting. BTW, awesome episode. Learnt some new things.

  • @mraaroncruz
    @mraaroncruz 6 หลายเดือนก่อน

    Long time vim user and never knew about *
    I always get value out of your videos. Thanks a lot!

  • @amqndin
    @amqndin 6 หลายเดือนก่อน

    the special clipboard register that is linked with the system clipboard is a + on windows, too.

  • @windowsrefund
    @windowsrefund 6 หลายเดือนก่อน

    Your videos are addicting. Being a big fan of motions, I often wonder why people typically use ciw to change a word rather than ce?

    • @roniqueh96
      @roniqueh96 6 หลายเดือนก่อน

      because ciw doesn't care where in the word your cursor is. ce = ciw only when your cursor is at the beginning of the word

    • @windowsrefund
      @windowsrefund 6 หลายเดือนก่อน

      @@roniqueh96 Yes, I remembered this later that day and couldn't agree more. It only makes sense in the event you're on the first character of the word.

  • @sirka0s
    @sirka0s 6 หลายเดือนก่อน

    Nice video! What is this prompt you are using btw, looks gorgeous!

  • @MatiasBaldanza
    @MatiasBaldanza 5 หลายเดือนก่อน

    Outstanding. I have a questions. The % register, in my mac, holds the full path and filename. How do I access just the filename and extension without the absolute path? (Been looking for it, but can't see if this is a setting or I have to look elsewhere.)

  • @kodder
    @kodder 7 หลายเดือนก่อน

    Linux has the + and * registers for the system. Since it has two different clipboards active at the same time usually. One is the one you use with ctrl+c/v and the other one is highlight and middle click.

  • @jaddadzakaria
    @jaddadzakaria 7 หลายเดือนก่อน +1

    we are all friends in this community, much love man 💜

  • @SamSepiol127
    @SamSepiol127 7 หลายเดือนก่อน

    actually, I don't remember if is actually my own config cause I set it up a few years ago, but for me "%p paste the absolute path(plus the name)of the file I'm currently in and imoo is kinda useful if you need to paste that to variables and stuff.
    Great video btw

    • @ivanheffner2587
      @ivanheffner2587 6 หลายเดือนก่อน +1

      This is a built-in for vim (maybe even OG vi). It pastes from the % register, which contains the current buffer’s filename.

  • @TheLANBeforeTime-uo9ph
    @TheLANBeforeTime-uo9ph 7 หลายเดือนก่อน +1

    not sure what I can learn from it but I know there will be. Liked, bookmarked for later watching! Peace out.

  • @rphyt
    @rphyt 6 หลายเดือนก่อน

    I don't mean to be pedantic but :s stands for :substitute not sed. Also in that command the '%' sign is used to tell :substitute to work on the entire file. The /g option, instead, means operate globally on the line.

  • @Viken43
    @Viken43 7 หลายเดือนก่อน +1

    Macros ftw thanks typecraft 😊

  • @onmico
    @onmico 4 หลายเดือนก่อน +1

    Which colorscheme are you using in this video?

  • @francisfish883
    @francisfish883 2 หลายเดือนก่อน

    % is short hand for 1,$ and you can use it anywhere a range would work

  • @sirhopcount
    @sirhopcount 7 หลายเดือนก่อน +2

    Excellent video 👍

    • @typecraft_dev
      @typecraft_dev  7 หลายเดือนก่อน

      Thank you! Cheers!

  • @xiaoliu6973
    @xiaoliu6973 7 หลายเดือนก่อน +1

    Great video. I have learned new things.

  • @joergw
    @joergw 7 หลายเดือนก่อน +1

    very helpful, thanks
    I really like your tutorials

  • @thonycsdev
    @thonycsdev 7 หลายเดือนก่อน +1

    Thanks nerd, congrats about the new sponsor

  • @ginger-viking
    @ginger-viking 5 หลายเดือนก่อน

    Great video, thanks!

  • @wiseskeshom4673
    @wiseskeshom4673 6 หลายเดือนก่อน

    Thank you so much, I learned a lot from this video.

  • @laggedskapari
    @laggedskapari 7 หลายเดือนก่อน

    Will love a video specially for nvim macros…..and as always Thanks Nerd!

  • @tomb6865
    @tomb6865 10 วันที่ผ่านมา

    Thanks for this! I learnt a few things I was unfamiliar with.
    Am I the only one who finds the use of " for registers awkward somehow? It's not really any different to any other key. Probably my brain is expecting to type a closing " somewhere and it messes me up!

  • @silak33
    @silak33 6 หลายเดือนก่อน

    Should be mentioned the 0-9 registers doesn't quite work as you mentioned here.
    0 will always contain the last yanked text, but 1-9 will only be populated if the text deleted is bigger than one line.

  • @MattRobinsonDev
    @MattRobinsonDev 6 หลายเดือนก่อน

    Another great video as always

  • @דניאלאביב-ו6ת
    @דניאלאביב-ו6ת 7 หลายเดือนก่อน

    Is there any way to configure vim buffer font, without setting the font of the terminal?
    I mean to have two different fonts for vim and the terminal that runs vim.

  • @serdar_k
    @serdar_k 5 หลายเดือนก่อน

    Great video, so great in fact that I went over to click the like button and saw that I had previously done so!

  • @laughingvampire7555
    @laughingvampire7555 3 หลายเดือนก่อน

    what about your neovim setup for ruby on rails development.

    • @typecraft_dev
      @typecraft_dev  2 หลายเดือนก่อน

      Join our free online workshop next week! learn.typecraft.dev/neovim-and-zellij-ruby-on-rails-edition/

  • @crazytony18
    @crazytony18 2 หลายเดือนก่อน

    It's a nice, well made video, but it's kinda missing the point in the usage terms. 'c' is not a motion, but rather it's an operator, which is important since the whole concept that vim works on is that you can use any oparator (like c for change) with any motion (like $ to jump to the end of a line) to perform that operation in the range between current character and the character at the end of the motion.

  • @timjames4306
    @timjames4306 7 หลายเดือนก่อน +1

    Please also make a video on how to config nvim with Django

  • @chandraprakashdarji
    @chandraprakashdarji 7 หลายเดือนก่อน +1

    Great video

  • @cristhianjhlcom
    @cristhianjhlcom 6 หลายเดือนก่อน

    Hey man I just found your channel and I think is amazing! Thank you 💯💯

  • @dark_sunset
    @dark_sunset 3 หลายเดือนก่อน

    What keyboard are you using?

    • @typecraft_dev
      @typecraft_dev  หลายเดือนก่อน

      HHKB Type S - check it out amzn.to/3C8iLwP

  • @RodGILLES
    @RodGILLES 15 วันที่ผ่านมา

    I really enjoy watching your videos and helpful tricks (thanks for making me redo my linux / vim config 300 times !)
    What I really lack (or am I too dumb to find one??) is a way to send some http requests, parse the result and store for example a token in a variable for future requests
    or even send a request that will first trigger my auth request to get the token automatically!
    Kind of postman / insomnia stuff.
    I have been struggeling with .http and .env files to get something I could use on all env for work

  • @blocSonic
    @blocSonic 7 หลายเดือนก่อน +1

    Thanks. You rock!

  • @SecretAgencyOfGaming
    @SecretAgencyOfGaming 7 หลายเดือนก่อน

    Thanks nerd! You taught me a lot!

  • @ronny332
    @ronny332 หลายเดือนก่อน

    ledur(??) ... le dur(??) ... L-D-U-R ... Left-Down-Up-Right(!!) ... as a non native english speaker I really hat to think about what you mean 🙂but it totally makes sense. Thank you!

  • @w01dnick
    @w01dnick 6 หลายเดือนก่อน +1

    You don't use relative line numbers, do you? A lot of people recommend them but TBH I don't feel comfortably with them for some reason.

    • @typecraft_dev
      @typecraft_dev  6 หลายเดือนก่อน +1

      Yeah never used them

  • @yasengo
    @yasengo 7 หลายเดือนก่อน

    How to solve issue when installed packages modules are being shown in suggestion while jsx module is not suggesting .

  • @Lars-ce4rd
    @Lars-ce4rd 7 หลายเดือนก่อน

    "I assume that you know some basic things like hjkl"
    Then proceeds to explain hjkl lol

  • @thayto_dev
    @thayto_dev 7 หลายเดือนก่อน +1

    the `*` blew my mind

    • @ivanheffner2587
      @ivanheffner2587 7 หลายเดือนก่อน +1

      You should also try #. It has the same thing as * but in the opposite direction. But remember: n and N on according to the direction of your previous search.

  • @glavataa
    @glavataa 6 หลายเดือนก่อน +1

    Going into Pane mode, Ctrl+P, then hjkl moves around, ESC when done

  • @binh1298ify
    @binh1298ify 7 หลายเดือนก่อน

    Thanks man, I learned some new things

  • @MatthieuPETIOT
    @MatthieuPETIOT 4 หลายเดือนก่อน

    👍
    better than your macro example:
    :2,9 norm ^i"^[A",
    to get this ^[ just type ctrl-v then escape.

  • @himquantum
    @himquantum 6 หลายเดือนก่อน

    Thank you, Nerd

  • @gjermundification
    @gjermundification 7 หลายเดือนก่อน

    9:48 Then again you forgot to `:set nu rnu` what is the use of being able to do stuff n times without rnu?

  • @KevinNitro
    @KevinNitro 6 หลายเดือนก่อน

    Hi my lord. Your terminal status line style is very cool. I love catppuccin :) Could you share your config? I would really appreciate that

  • @Cleanblue1990
    @Cleanblue1990 7 หลายเดือนก่อน +2

    Finally i know how to exit vim

  • @midjhelins8383
    @midjhelins8383 5 หลายเดือนก่อน

    excellent!

  • @RCMoret
    @RCMoret 5 หลายเดือนก่อน

    Personally I’ve never been able to get into macros. They always seem to be too much trouble. I could do your example just as fast with visual block mode as I can with a macro.

  • @w01dnick
    @w01dnick 6 หลายเดือนก่อน

    8:43 or use %w (in this case)

  • @hey_james
    @hey_james 7 หลายเดือนก่อน

    Is the moustache a requirement now if you have a developer youtube channel?