3 Levels of Vim Refactoring

Поделиться
HTML-код
  • Опубликовано: 26 янв 2025
  • НаукаНаука

Комментарии • 189

  • @mahirabbas3700
    @mahirabbas3700 9 месяцев назад +93

    thanks nerd

  • @ziggy-dev
    @ziggy-dev 9 месяцев назад +180

    I own a record player, love French press coffee, run a tiling window manager on Arch (btw), but would use the LSP rename. Now I'm having an identity crisis.

    • @typecraft_dev
      @typecraft_dev  9 месяцев назад +19

      lol

    • @nickmills8476
      @nickmills8476 9 месяцев назад +9

      Use whatever works, but whatever you use, use vim…

    • @t0mmy44h
      @t0mmy44h 9 месяцев назад

      Espresso machine and high end DAC but yes me too, in fact I did a bit of all of this two days ago at work :/

    • @neniugrava
      @neniugrava 9 месяцев назад

      I listen to lossy music over good (but not gold-plated) Bluetooth headphones, use an aeropress, run neovim in WSL in Ubuntu on Windows, and I would probably just :windo or :tabdo a %s because I already know which files use the function being renamed.
      I would use the LSP, but building C/C++ projects on Windows does not play nice with clangd running in Linux 😢, and I'm too lazy to make something to reformat my compile_commands.json to work 😂.
      I should really start to use vimgrep more, though...

    • @BiGreDNoSecoMpAny
      @BiGreDNoSecoMpAny 9 месяцев назад +1

      You should ditch the French Press for a V60, you’ll get better coffee instantly - there’s a reason you don’t get a French press in any good Café

  • @pbnjdev
    @pbnjdev 9 месяцев назад +91

    Nice video.
    Just a minor correction about what the neckbeard would do:
    1. The neckbeard would know from experience that `:vimgrep` is painfully slow and would use `:grep` which calls an external grep utility as specified by `grepprg` vim option (`grep -n $* /dev/null` by default, but can be customized to anything else `let &l:grepprg = 'rg --vimgrep --smart-case $*'`)
    2. The neckbeard would proceed to run a grep command on the relevant files/directories to exclude unwanted results (e.g. css), like `:grep "@?(p\|P)osts?" path/to/*.rb`
    3. Lastly, the neckbeard would run a precise substitution command on the quickfix entries while preserving case-sensitivity and save the modified buffers in one-go, like `cdo %s/\(p\|P\)ost\(s\)\?/\1oop\2/g | update`.

    • @craigdanielmaceacher
      @craigdanielmaceacher 9 месяцев назад +1

      `:noauto vimgrep` helps with speed

    • @ivanheffner2587
      @ivanheffner2587 9 месяцев назад +4

      Or, as one well who takes “use the best tool for the job” very seriously, I would… I mean, “the neckbeard”… would use `git grep` since this is definitely in a git repository, using the `-l` option to only list the files, which would then be used as the file list for some quick `perl -pi -e` to do the substitution on all files.

    • @valbogda5512
      @valbogda5512 9 месяцев назад +16

      Both the video and this comment are super accurate at capturing the essence of a neckbeard.
      However, as a neckbeard I would not use vim for this task. Instead, I'd just grep (ripgrep nowadays, times are changing) and once I'm satisfied that I'm capturing just the right stuff I would pipe the list of files to an inline substituting `sed` incantation. Of course, all this would be done inside of a git repo so that the final result can be inspected and conveniently re-done if needed.
      PS. If I'm on a system that lacks `sed` I would use `perl` as a poor mans `sed`.
      `perl -pi -e 's/Posts?/poop/i' (rg -li Posts)`

    • @plaintext7288
      @plaintext7288 9 месяцев назад +7

      My neckbeard grew 1mm just from reading this

    • @ivanheffner2587
      @ivanheffner2587 9 месяцев назад +5

      @@valbogda5512 “perl as a poor man’s sed”? o.O?

  • @freewarehunter
    @freewarehunter 8 месяцев назад +3

    I think this might the highest value-per-minute RUclips video I've ever watched.

  • @nossal
    @nossal 9 месяцев назад +52

    More options:
    - Telescope -> Quickfix -> cdo
    - nvim-spretre

  • @2EOGIY
    @2EOGIY 9 месяцев назад +24

    My notes from video how to refactor:
    - buy a vinyl player;
    - grow beard;
    - poop a lot;
    - bookmark this video.
    Thank you, Good job.

  • @dhakhoa93
    @dhakhoa93 9 месяцев назад +44

    You should be able to use `:cfdo` instead, which would run the command for all the files, not all entries, in the qf list, especially in this case where you already use %s to substitute the whole file.

    • @typecraft_dev
      @typecraft_dev  9 месяцев назад +10

      very nice, learn something new every day! :)

    • @gokayburuc
      @gokayburuc 9 месяцев назад +2

      Telescope + quickfix + :cdo + vim regex

  • @starmechlx
    @starmechlx 9 месяцев назад +6

    Man, as a new (6 months in) Neovim user, I literally just learned about the quickfix list from The Primeagen like yesterday. Seeing it here again today doubled down that I need to start using this and get comfortable with it. Way too much goodness here.
    On a separate note, I just have to say how much I love the aesthetic of these videos. Also, I was a Dracula guy before, but you have turned me into a Catppuccin nerd, so for that: thanks nerd.

    • @typecraft_dev
      @typecraft_dev  9 месяцев назад +1

      Awesome! glad you're getting something out of these videos! welcome to the vim cult, brother

    • @DestopLine
      @DestopLine 9 месяцев назад

      Same here, I learned about it from him on his video with the _Elixir_ guy

  • @wiseskeshom4673
    @wiseskeshom4673 8 месяцев назад

    Thanks to all hipsters the config wizards, neckbeards and nerds, I learn new things about Vim every time I come here. nice work :)

  • @MrSnivvel
    @MrSnivvel 9 месяцев назад +7

    Great info. I know I'll be rewatching the 'neckbeard' part a few times to catch all parts. In my mind, striving to be in both the 'neckbeard' and 'config wizard' camps is going to mean being the most productive in using Neovim.
    Thanks for this video, nerd! 🤠

  • @brentpappas4055
    @brentpappas4055 16 часов назад

    Thank you for the video :)
    I honestly was expecting the last user to just leave vim and run find+sed directly in their terminal; instead I learned something new!
    Also one small tip: if you want to try the last approach to perform a project-wide find and replace, make sure to set awa (autowriteall) beforehand like so: `:set awa`. This will prevent vim from giving you errors about unsaved changes when moving between files with find and replace.

  • @DrkGrntt
    @DrkGrntt 9 месяцев назад +3

    This is fantastic! Great timing too, I need to do this in a couple of hours. I'm fairly new to vim, so your content has been super helpful, thanks!

  • @aayushbajaj2260
    @aayushbajaj2260 9 месяцев назад +1

    you know so much. I've been using vim for like 3 years, I don't know this much yet! also your presentation is cool :>

  • @j1d7s
    @j1d7s 9 месяцев назад +1

    Great comparison, I did not know where this was going beforehand and I am usually in the LSP camp, so I thought I already knew the "best" way. The neckbeard approach was new to me, I did not know there is this great builtin way.

  • @Mr_Smørrebrød
    @Mr_Smørrebrød 9 месяцев назад +2

    This "3 levels of ..." is a very nice format! More please 😁

  • @lukeemhigh
    @lukeemhigh 9 месяцев назад

    Great video, as always. I use LSP rename when available and Telescope->Quickfix->cdo when editing stuff like Helm charts or stuff where the LSP does not have the rename functionality baked in. On arch (btw) running a tiling WM (btw).
    Thanks nerd!

  • @gunarcom
    @gunarcom 9 месяцев назад +1

    You have some of the most informative videos in the space, thank you!

  • @ivshofspb
    @ivshofspb 9 месяцев назад +1

    I do appreciate this approach . Howeve it is still looks like magic and I feel more confident using Notepad++

  • @ethandoescode
    @ethandoescode 9 месяцев назад +2

    Have been using your neovim for noobs config and adding to it myself for a few weeks. Did not realize that I could use that lsp binding for refactoring haha. I guess I’m transitioning from hipster stage ever so slowly

  • @PetrenkoAndrii
    @PetrenkoAndrii 9 месяцев назад +2

    Wow! This was something. I have to rewatch this video couple of times being :%s/one/two/g type of vim user. Thanks for cool video!

  • @throwaway3227
    @throwaway3227 9 месяцев назад +2

    Neckbeard here (apparently), but just wanted to point out that you don't need any plugins (lspconfig included) to run an LSP in Neovim.

  • @Denis-wf4bl
    @Denis-wf4bl 9 месяцев назад +4

    Great video, I learned a lot here! I love the three characters, please post more educational videos with them. Thanks Nerd 🥰

    • @typecraft_dev
      @typecraft_dev  9 месяцев назад +1

      will do! thanks for being a memner, nerd!

  • @VovaY
    @VovaY 9 месяцев назад +5

    I'm a configuration wizard, I even grew the exact same mustahe

  • @muizzyranking
    @muizzyranking 9 месяцев назад +1

    this is actually a fun one, thanks nerd.

  • @alanis4AL
    @alanis4AL 9 месяцев назад +1

    Love your content the way you explain things is perfect
    I hope you don’t get this wrong but the only thing I would suggest is drop the intro you don’t need it
    Ps. Thanks for sharing your knowledge with us

  • @mattweidner
    @mattweidner 9 месяцев назад +3

    Neckbeard status confirmed.

  • @Anthony-pln
    @Anthony-pln 9 месяцев назад +1

    Hey that was a creative format. Kudos. Fun and interesting.

  • @utvikler-no
    @utvikler-no 9 месяцев назад +2

    Awesome as always ❤

  • @chandragie
    @chandragie 9 месяцев назад +1

    always new things to learn in vim 👍🏻👍🏻

  • @zaubara1543
    @zaubara1543 4 месяца назад +1

    I would be the "stumbles down the stairs" -User:
    -assignment is to code mobile robots in ros
    -learn that ros runs only on ubuntu 20.04
    -run it on a vm because dualbooting my laptop for an old distro to use only one framework seems wasteful
    -learn that vms are notorious for not correctly executing or displaying some ros addons
    -notice this new magic thing called docker
    -try to use other dockerfiles to build my ros setup, but fail miserably in setting up vs code correctly
    -be angry at vs code and use the bloody terminal
    -run ros docker image via wsl2 on windows
    -setting up my first ros nodes, but now there are at least 4 terminals open at any given time
    -learn about tmux and feel like a wizard
    -missing the pretty colours and assists of vs code
    -learning about vim
    -now this bloody rabbit hole with plugins and lua, but gods do I feel strong
    TLDR; Wanted to program whats basically a roomba but learned how to manipulate lua instead

  • @maguilecutty
    @maguilecutty 9 месяцев назад +2

    What about the user who is smart enough to use telescope and a macro to have the same control as the neckbears and uses a key map to make it happen?

  • @pritamdodeja
    @pritamdodeja Месяц назад

    Wouldn't the neckbeard know about \? Amazing stuff as always!

  • @Naparajith
    @Naparajith 9 месяцев назад

    Nice video. Really helped me level up my NeoVim game.

  • @RazoBeckett.
    @RazoBeckett. 9 месяцев назад +2

    hey , hey, hey look who is back !!

  • @NormalNvim
    @NormalNvim 9 месяцев назад +1

    Color me impressed. This is great content.

  • @Viken43
    @Viken43 9 месяцев назад +2

    I am quite a new user to vim, only really use it for basic editing. Typecraft is improving my knowledge almost ready to start using hjkl keys 😊… I use Arch BTW

  • @ThatBidsh
    @ThatBidsh 9 месяцев назад

    glad u went more in depth on cdo because i learned a thing! lol

  • @techedzee
    @techedzee 9 месяцев назад +1

    Damn. I love the neck beard flow

  • @thadrunsfaster
    @thadrunsfaster 9 месяцев назад +2

    I’m a mix of three. I’m a neckbeard-hipster-plugin?

  • @bagfleet
    @bagfleet 9 месяцев назад +1

    Great vid! Love your videos!

  • @carlweiscodes
    @carlweiscodes 5 месяцев назад

    Hell Yeah, Brother! Thanks Nerd.

  • @vanvothe4817
    @vanvothe4817 9 месяцев назад +1

    I just installed 2 plugin vim: oil + nvim-surround. Use vim is a simple text editor, all remaining operations use the terminal

  • @Milaweak
    @Milaweak 9 месяцев назад +1

    MORE MORE MORE videos like this !!!!

  • @davidjohansson8476
    @davidjohansson8476 9 месяцев назад +2

    I don't believe this was said, but one advantage of relying on something like grep instead of lsp is that you get updated documentation/comments for free.

  • @iamfishmind
    @iamfishmind 9 месяцев назад +1

    i have a french press 😅 but personally would use the "find & replace" function in any number of gui software with navigation tree in side panel

  • @AderynCrow
    @AderynCrow 9 месяцев назад +1

    Thanks for calling me a neckbeard, really needed that. I shave daily, but your description fits perfectly. I only don't use vim as an alarm, but I have a vim setup where I have a clock in it's own tile in vim, so that's kinda similar

  • @rodelias9378
    @rodelias9378 9 месяцев назад +1

    Thanks Nerd. Great video btw

  • @gorudonu
    @gorudonu 9 месяцев назад +1

    oh I didnt know about global replace, thanks!

  • @TheEriksen123
    @TheEriksen123 9 месяцев назад +1

    Love this, would like to see more examples!

  • @johnnyboard78
    @johnnyboard78 9 месяцев назад +2

    The neckbeard would rather quit with `:xa`, less characters typed + it only saves the buffers that were modified

  • @felipegutierrez2944
    @felipegutierrez2944 9 месяцев назад +1

    how do you manage http requests, with postman or with a nvim plugin? Great Content!

  • @Freshbott2
    @Freshbott2 9 месяцев назад

    What I really want is neovim but without all the endless setup and constant learning. Is there a good tool that lets you search commands like you would in Blender or AutoCAD?

  • @msmoser
    @msmoser 9 месяцев назад +2

    This would have been a perfect video if it had the ethereal “LDUR” background voice….

  • @darksinge
    @darksinge 9 месяцев назад +1

    As a neckbeard, I'd use cfdo when making multiple file changes, as it's more efficient than plain ole cdo 🤓.

  • @nothiiiiiiiing
    @nothiiiiiiiing 9 месяцев назад +2

    LSP rename or sed, i do use helix but should be equivalent

  • @hapaise2924
    @hapaise2924 9 месяцев назад +1

    thanks! Make a video on dotfiles on how we can make dot files for nvim config, tmux, I have yabai and all that so we can use it on another machine with just one command

  • @howuseehim
    @howuseehim 3 месяца назад

    You gonna love this, so I quit vim, went to vscode cmd shift f replaced all occurrences, save, went back to nvim looked around to see if someone noticed.

  • @catwhisperer911
    @catwhisperer911 9 месяцев назад +1

    Using LSP rename only works in the current buffer for me. Are you using one or more additional plugins to have it work across multiple files?

    • @typecraft_dev
      @typecraft_dev  9 месяцев назад

      Not sure. It works in solargraph and ruby

  • @thehiddenplace
    @thehiddenplace 8 месяцев назад +1

    I love that the hipster has a macbook and the conf wiz a framework laptop. I use both, where does that put me?

    • @typecraft_dev
      @typecraft_dev  8 месяцев назад

      A menace to society

    • @thehiddenplace
      @thehiddenplace 8 месяцев назад

      @@typecraft_dev Ok that's not too bad, I thought it made me a hyper-hipster.

  • @rendivs
    @rendivs 7 дней назад

    The last one is so cool and usefull :)

  • @noisycarlos
    @noisycarlos 9 месяцев назад +1

    which ruby or rails lsp are you using?
    h

    • @typecraft_dev
      @typecraft_dev  9 месяцев назад

      Solargraph

    • @typecraft_dev
      @typecraft_dev  4 месяца назад

      Things have changed since our last comment. Want to find out our setup for Rails now? Join our free workshop next week - learn.typecraft.dev/neovim-and-zellij-ruby-on-rails-edition/

  • @mahaddev
    @mahaddev 6 месяцев назад +1

    Bookmarked this

  • @xXrandom
    @xXrandom 9 месяцев назад +4

    Let's gooooo

  • @gjermundification
    @gjermundification 9 месяцев назад +1

    cdo all the way to goal.

  • @laughingvampire7555
    @laughingvampire7555 5 месяцев назад

    I bet the neckbeard is not even using neovim, he is using his own Bram's vim setup written in viml 20 years ago

  • @Cool-Linux-Penguin
    @Cool-Linux-Penguin 9 месяцев назад +5

    Sorry for being 30 minutes late.

  • @binh1298ify
    @binh1298ify 9 месяцев назад

    thanks man. cool video

  • @juanmacias5922
    @juanmacias5922 9 месяцев назад

    So helpful, thanks!

  • @Szymonides252
    @Szymonides252 9 месяцев назад +2

    I use arch btw and I still confuse 'j' with 'k' in vim 😅

    • @typecraft_dev
      @typecraft_dev  9 месяцев назад +1

      fellow arch brother

    • @ChrisCox-wv7oo
      @ChrisCox-wv7oo 9 месяцев назад

      What helped was thinking index finger is stronger than middle finger, and going down in a file is more common than going up.
      Strong finger down. Less strong finger up.

  • @TreeLuvBurdpu
    @TreeLuvBurdpu 9 месяцев назад

    I like the last one but with \b to avoid postcss

  • @gjermundification
    @gjermundification 9 месяцев назад +1

    4:32 Gem^^

  • @joshysmarty2540
    @joshysmarty2540 9 месяцев назад +1

    I need more nvim videos!.

  • @pavloburyanov5842
    @pavloburyanov5842 9 месяцев назад

    who am I if I use all 3 approaches?

  • @disguisedpigeon5465
    @disguisedpigeon5465 9 месяцев назад

    IMO the config wizard way is optimal when you are coding and the neckbeard one is better for documentation, but the hipster way falls short of usefulness when you have the other two. Telescope is great for navigating files and such though. PRAISE LORD TEEJ

  • @Megabeboo
    @Megabeboo 9 месяцев назад +1

    Show us your keyboard! It sounds nice.

  • @will_1536
    @will_1536 9 месяцев назад

    Bro if I could rely on my omnisharp lsp to always work like it does in VisualStudio I would just use that rename, but because it often doesn't, I'm forced to be a neckbeard

  • @jamlie977
    @jamlie977 9 месяцев назад +1

    damn it, i'm not a neckbeard

  • @CalvinB_
    @CalvinB_ 9 месяцев назад +2

    FRAMEWORK, laptop!! sorry still love seeing them.....

    • @typecraft_dev
      @typecraft_dev  9 месяцев назад

      stay tuned!!! video about the framework coming up

  • @RomanLi-y9c
    @RomanLi-y9c 9 месяцев назад

    sed can do it, how about macro over quickfix?

  • @craigdanielmaceacher
    @craigdanielmaceacher 9 месяцев назад +1

    `:cdo update` so you aren’t touching modified times on unedited files

  • @EduardoAlvarez-fm6zi
    @EduardoAlvarez-fm6zi 9 месяцев назад +1

    Arch? For a neckbeard? Pffft. Slackware ;)

  • @schlesser
    @schlesser 9 месяцев назад +1

    Awesome

  • @loutrea
    @loutrea 9 месяцев назад +1

    ok I'm a hipster neckbeard wizard as I use the 3 methods, depending on, well, I don't know.

    • @loutrea
      @loutrea 9 месяцев назад +1

      great video btw, keep going. I didn't know what "french coffee" is, and as a French, it makes me laugh :)

  • @lightningpheonix7785
    @lightningpheonix7785 9 месяцев назад

    I am the neckbeard guy 😂 also with keybindings instead of typing commands

  • @dezly-macauley
    @dezly-macauley 9 месяцев назад +1

    I use the s with /gc command and oil.nvim to keep my files named consistently. Now you're telling me I can rename things WITHIN multiple files with :cdo... dude this too much power!
    I still don't have a neckbeard but I just got one step closer 😆

  • @mateusfreira
    @mateusfreira 9 месяцев назад +1

    Do I need mustache to be a RUclips developer?
    Great content and edition, thank you.

  • @fisk_00
    @fisk_00 4 месяца назад

    Combine cdo with telescope and quickfix

  • @Tarekconqueso
    @Tarekconqueso 9 месяцев назад +1

    so you're telling me the so feared vim hipster does not know about :cdo s/ hmmmmmm

  • @yashrajdargan2203
    @yashrajdargan2203 9 месяцев назад +2

    great acting nerd!!!

  • @laughingvampire7555
    @laughingvampire7555 5 месяцев назад +1

    Poop: pure object oriented programming

  • @12crenshaw
    @12crenshaw 9 месяцев назад

    Imagine just using normal 21st century graphical editor and doing this in 5 sec without any stress

  • @FilipGodlewski
    @FilipGodlewski 9 месяцев назад

    Don't forget about CFilter

  • @JoshPeterson
    @JoshPeterson 9 месяцев назад +1

    You're obsessed with "poops"

  • @valbogda5512
    @valbogda5512 9 месяцев назад +1

    Hello, have I stumbled upon the secret Archilinati society?

    • @typecraft_dev
      @typecraft_dev  9 месяцев назад

      yes you have. welcome, brother

  • @DarinNelson-w5v
    @DarinNelson-w5v 9 месяцев назад +1

    `:bot copen`, because his terminal is split vertically. Do I need a shave?

  • @undg_dev
    @undg_dev День назад

    4:41 I use Arch BTW >;-]

  • @simonlauer9379
    @simonlauer9379 9 месяцев назад +1

    I use NixOs btw
    just dropping it in 😂

    • @typecraft_dev
      @typecraft_dev  9 месяцев назад

      Love the concept of nixos. I'm going to have to look into it more in the future

  • @borislavgalchev
    @borislavgalchev 9 месяцев назад

    Yo nerd, are you using linux awesome?

  • @itsrobelschwarz7248
    @itsrobelschwarz7248 9 месяцев назад +1

    fuck I hate bring a neck beard man, I am 19 years old, why do I run a tiling window manager (Qtile) on arch and use the "neck beard refactor" method(I don't have facial hair)

    • @typecraft_dev
      @typecraft_dev  9 месяцев назад +1

      sounds like you are just wise beyond your years :)

  • @lexdysia9119
    @lexdysia9119 9 месяцев назад +1

    tell us you don't like our posts without telling us you don't like our posts :)