3 Levels of Vim Refactoring

preview_player
Показать описание

We are going to cover the three different ways users could refactor something in Vim. In Vim you can do things many different ways and we are covering three of them:

1. hipster - has telescope but no LSP setup
2. neckbeard - doesn't rely at all on plugins, uses built in vim functions
3. config wizard - has the perfect config set up. and uses LSP rename functionality

There are many ways to do things in vim, its part of what makes it so fun!

chapters:
0:00 - intro
0:52 - hipster refactoring in vim
2:11 - configuration wizard LSP refactoring
4:16 - neckbeard refactoring without plugins
7:00 - wrapping up
Рекомендации по теме
Комментарии
Автор

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.

ziggy-dev
Автор

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 | update`.

pbnjdev
Автор

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

nossal
Автор

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

EOGIY
Автор

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.

starmechlx
Автор

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

freewarehunter
Автор

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.

dhakhoa
Автор

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! 🤠

MrSnivvel
Автор

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

wiseskeshom
Автор

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.

brentpappas
Автор

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.

jds
Автор

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

Mr_Smørrebrød
Автор

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

ethandoescode
Автор

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!

DrkGrntt
Автор

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.

howuseehim
Автор

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 :>

aayushbajaj
Автор

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!

lukeemhigh
Автор

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

ivshofspb
Автор

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

gunarcom
Автор

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!

PetrenkoAndrii