How to Vim in 2023: Tips and Tricks
Key Takeaways
ThePrimeagen shares tips and tricks for using Vim in 2023, focusing on utilizing plugins and creating a complete experience, with links to resources such as his Twitch channel and GitHub repository for VimRC and i3 configurations.
Full Transcript
you have your LSP configured and ready to rock telescope is looking good Harpoon because you're a real one you even have undo tree Ready Get integration with fugitive but every time you open Vim you just look at that blinking cursor you don't even know how to use Vim so in this video we're gonna go through how to actually use them how to use it effectively and we're going to resolve a conflict we're gonna fix a bug and so I just wanted you to be excited I want that appetite wet so let me show you how to use vim and if you don't have your Vim setup I have a Vim setup RC video right here so what we're going to be doing with Vim today is actually solving a bug when I'm running a cargo and trying to build the Chad stack if you're not familiar with the chat stack I mean you clearly haven't been on Twitch recently what but it's the most aggressive the most sweatiest the greatest web development stack ever created of course which is Cobalt Haskell alpine.js and Docker Chad material so effectively how Chad sack works is that it takes the Pages directory and it will actually walk through the directory and create your application so show sum has a variable path right here called value one it has a variable path called value two and then as this index.html which gives you a nice and beautiful message that all Chads approve of since we're using Haskell it does a CGI bin Gateway into our Cobalt program so what it needs to do is generate out a controller called show some and then it also needs to generate out the view template called show sum and that is what our chatter program is which of course you have to use rust as well the tool the build tool can be built in Rust for the Chad stack and so I want to be able to execute chatter and boom build Chad stack so what is the error well if I go like this cargo run we get the weirdest error right here it says no such follow directory if I just simply add in a rust back trace it will tell me where did this error happen so if I jump all the way up here you'll see right here Main 45 so let's jump over and let's open up Vim to the current directory when I get here I'll see this tree view so I guess I could go to Source press enter go to main press enter type in Colon 45 and jump down to that but that's kind of inconvenient right you don't want to have to use the file tree file trees are just not all that useful unless if you're creating or deleting things so let's quit them and let's do it again I'll reopen it up at this directory but I'm going to press Ctrl P which will open up telescope if I was a bit more zoomed out it would actually give me that nice little view to what's actually inside the folder so I can start typing out Main and you can see Maine's contents on the side but since we're on YouTube baby you know we gotta be all nice and kind of small here so I'm going to type in main fuzzy find my way there press enter and look at that we're in main colon 45 to jump to the line and look at that we're failing writing out the controller path so why is that let's find out so I'm going to press FC jump over to the controller GD jump to definition if you've watched my setting up neovim from scratch you would know GDI use it inside of LSP zero to jump to definition you can even see right there Vim LSP buff definition boom takes whatever's under your cursor and jumps to its definition all right so I'm looking right here and I can see right away that you have this controllers directory and then I write out my controller dot Cobalt so I should be trying to write showname.cobol so what's the problem if I jump back here and I go LS what do you see do you see the folder controllers no do you see the folder views no you don't so how much do you want to bet we need to create those directories so let's jump back here now I can fuzzy find my way back and by pressing main but that's kind of like meh I can also press Ctrl carrot which will jump back to my previous file it's called alternate file it's fantastic I use that jumping all the time but my personal favorite form of navigation is actually Harpoon so I'm going to press leader a which will append this current file which is main file to my Harpoon list I'll use alternate file to jump back to my pages one press leader a added to my Harpoon list if I press Ctrl e it'll show my Harpoon menu you're gonna have to set up your own remaps to be whatever you like these are the remaps I like you can see I have main on my first pages on my second and now I can just press a single key and go back and forth between them I have it on control h and T since I use Dvorak by the way I use Dvorak and program and rust and use neofam Chad okay this is a Chad stack anyways so I just press Ctrl H or T and I'll jump to it so since I want to be in main I'll press Ctrl H now I'm in main so let's validate that our fix actually works I'm gonna go like this uh standard FS create directory and let's create a controller controllers so now this should cause us to fail but this time on line 48 look at that it should cause it on line 48 so we should be able to see that so let's go back here let's rerun it with the back Trace there we go it did fail and where did it fail at line 48 so it was the problem we just didn't have the directory there I'll jump back into Vim I will then jump up seven highlight do that delete out the contents with the the classic CI double quote which will jump to the first string and then delete out its contents look at that copilot's even giving me the answer of course I want views press tab to complete it save it jump back here rerun it we're good we're looking good do a little LS on the controllers you can see other app and show some being generated if I cat out controller or views uh other app we should see suck it Melky the only appropriate thing to say to him because you know I wanted to make a small div and we all know milky has a small div right right let's actually do it a little bit better so I'm going to use Ctrl P I'm gonna go to Pages I'm going to go to other app index.html jump in here and let's turn turn that div to a p save it jump back here re-execute that cargo run let's cat back out the other app look at that milky now has a small P chat stack all right so let's Harpoon our way back to the main file so I'm going to just execute Harpoon list item one jump back to the main let's make this a little bit better because if you think about it if I go six down jump to definition this thing has the word controllers down here if I use alternate file this thing has controllers over here let's use Harpoon jump back to Pages you can see we don't want this this kind of sucks right so let's go up to the top and let's go public const controllers which is a Ampersand string we'll do that let's highlight gank paste F capital c d c i w for cut out word views CI double quotes for cut out inside of quotes type in the word views hit save Harpoon our way all the way back to our main file CA double quotes now we're looking good go controllers if I press yes on the autocomplete right here notice that it says use Pages it will also Auto Import it for me notice that my screen went down one if I press asterisk it will search for this instance within this file and then I can use next to jump around you can see up top it included it let's jump back down here see a double quotes views now here's the problem I didn't use the autocomplete to complete it therefore it's not in our file right now right we're not actually importing it so if I write look at that we have ourselves a problem if I jump back to my LSP folder over here you'll see right here that I have this whole Vim code action going on here this will perform a code action with your LSP which if your LSP is properly set up you will be able to do some Auto fixing so I do Vim code action it's going to say hey do you want to import or do you want to qualify if we choose qualify look at that that's pretty cool right let's undo that and let's execute again let's press import if you jump back up here you'll see that controller views awesome I'm going to press Ctrl o jump back from Once I came I'm going to hit save once LSP analyzer runs One More Time Boom everything's looking good let's actually jump back to our Pages file and then let's press asterisk to search for controllers we're back here ciw let's do a little squirrely brace here jump over F comma to jump over here press a space controllers I'm going to press Ctrl n to go down to the next one Ctrl y to accept it yes comma leave it save it because I'm a chronic saver maybe save four times just to make sure five down capital F semicolon back here a space views comma save and it's gonna say hey you can't do that so we're gonna go capital F little v c i w put in one of those hit the save jump back to the main and everything's looking good go over here re-hit the old cargo build and beautiful we got it but you know what we need to do we need to create a merge conflict because we want to be able to actually show off some of the cool parts of them especially when it comes to merge conflicts and working with Git so right now you're probably already pretty impressed so this whole like git conflict resolutions just feels like so much so if you are hey press like press the Subscribe button send me the signals that you enjoy it and if you do send enough I will make a video about how I'm actually going so fast between everything being able to jump between Vim the command line and everything and give you a further like meta workflow on how to use your computer effectively because we could make it even better we could go over to our browser back to here back to our browser back here as fast as you would like so press those buttons let me know in the comments before we create that git problem I did want to show you one kind of cool thing I want you to notice up here that it says line 22 1817 like what the heck's going on up here well this little top item is called context tree sitter what it does is it grabs whatever you're in and puts it on the very very top so if I were to create a bunch of space you here notice that the four Loop stays there which means that since I use relative line numbers I could go like this 42 up whoopsies 42 up it will jump up to that line it's told me where I'm at if I use control oh I'll jump back all around oopsies I personally find context to be really awesome definitely use it it's called Neil Van all right so now on to get I use leader GS leader get status it shows me the status of my git I can actually work with it I can press equal sign to look at all the differences remember when we had we made milk you could have a small p i can press equal to undo it I can also visually select a chunk and press s to only commit to that chunk so if I jump down to the bottom you'll see that I have staged just that one chunk but not everything so you can chunk by chunk grab it or you can just press s on the entire file it's beautiful so let's just commit all of our changes right here and instead of actually committing it I'm going to press czz which czz actually is going to stash the changes so there we go we have the changes stashed we're back to our old error we're not having any change of code all right so let's create the conflict so effectively what I want to do is take our old code we had because we stashed all of our changes and I want to put duplicate code that's slightly different in the same spot so what I'm going to do is I'm going to use undo tree so space u will actually give me everything that has happened within this file so if you look at this my cursor is now on this file here's all the changes we've done I'm going to use Ctrl w h to jump over and I'm going to go back to about seven minutes ago now I'm going to press Ctrl w l to go to this one I'm going to press Ctrl D to jump down by half page there's the thing I want y AP Yap the paragraph Yank It Ctrl w h back over GG to go to the top press enter on this one now we're in the latest change I'm going to control W back to over here the control w o to close all the windows and now I can just press shift p to give it that nice paste upper like that I like kind of you know nice little white space hit save but I want to make it different right I don't want to have the same change so check this out all right so let's make a change so that they're different and it'll cause a conflict so I'm gonna go ciw quotes control thank you uh copilot for introducing that syntax error ciw quotes do the same thing awesome thank you for not the syntax error that time cool job co-pilot all right so this is obviously different than it was last time now we should have a conflict I'm going to save it re-get status see my new change I'm going to press s to save this cc to commit this and I'm gonna go like this fix uh the controller and view folders save that file it's now committed that now I want to pop off my stash that's broken so I go CZ capital A by doing capital A it forces the pop and we've created the whole conflict look at the conflict right here we have a better fix in place but everything's broken so let's Jump Up In Here Again control w o you can do control W control o control W Capital control W control shift L it just they all work if I press U on on stage you can see the difference but fixing these things like in place is just like that's not fun I don't want to have to jump into the file and fix it by hand that sucks so instead what I'm going to do is I'm gonna press DV while on Main and then I can see the change actively on both sides so let's do that I'm going to close this file zoom out a bit Ctrl W equal to equal all those things and you can see okay so I have this side which has the controllers and views hard-coded or this side that has the controller and Views as a variable from the pages one well I want this one so I'm going to do this I'm going to go GH and it's going to select this side on that conflict I'm going to hit save once and we should start seeing these errors going away there we go the errors went away but what was that GH I have this remap right here that executes a diff git and I either get left or right and remember since I used Dvorak by the way U is First Finger power finger on my right hand so I'm going to get the right hand side with my power right hand finger or I'm going to get my left hand power finger which is going to be the U so U is left hand I think I said that backwards H is right hand there we go just so g u g h wait said that backwards g h g u yeah got em it makes more sense when I'm typing it because of course it's just located so it's like gu I'm just going to that side it just makes it easy because I'm going right here this finger that side this finger that side so there we go the conflict has been resolved so I don't need these two outside windows so what I'm going to press is Ctrl w oh close everything Zoom back in for y'all press save that looks beautiful right when I go to GS you'll notice that I still have this one unstaged I still have this one on stage so I'm going to press s commit everything now our main changes actually has in the controllers and the two things you can see we removed the hard-coded ones we have now our new variable ones I'm going to press c c and go like this fix the proper fix you know nothing like a good thing oh all right so let's actually commit this let's push this up to master so leader P this is another remap I have that's just gonna execute git push but look at that I don't have my Upstream set so I'm gonna actually use tmux I'm gonna use Ctrl a Open Bracket yank that line hit the colon paste it in jump all the way back erase everything capital G get because fugitive comes with a git wrapper included press enter it's gonna push it upstream and we're gonna track the branch and so that's using Vim notice that you can use vim and you can have the same experience you get with any high powered really sluggishly slow use your mouse editor or you can just get that keyboard Centric development flow which clearly is just the most efficient way to edit text so again please hey like subscribe give me a comment I really appreciate that if you appreciate this and you do want that total tmux I3 Vim combo workflow I will know to make it based off how you respond the name I'm pointing way too long at you the name is the primogen
Original Description
This is not another tutorial on how to do some key combos or how to install plugins, its about _using_ the plugins and everything together to have a complete experience! I hope you enjoyed it!
### Twitch
Everything is built live on twitch
Twitch : https://bit.ly/3xhFO3E
Discord: discord.gg/ThePrimeagen
Spotify DevHour: https://open.spotify.com/show/4MLaDrQcQ5mi3rsnvWkwPt
### Editor
All my videos are edited by Flip. Give him a follow! https://twitter.com/flipmediaprod He is also open to do more editing, so slide deeeeeeeeep into his dms.
Join this channel to get access to perks:
https://www.youtube.com/channel/UC8ENHE5xdFSwx71u3fDH5Xw/join
### Links
Linode: https://linode.com/prime
https://discord.gg/ThePrimeagen
Twitch: https://twitch.tv/ThePrimeagen
Insta: https://instagram.com/ThePrimeagen
Twitter: https://twitter.com/ThePrimeagen
VimRC & i3: https://github.com/ThePrimeagen/.dotfiles
Keyboard 15% off https://bit.ly/Prime360 USE CODE PRIME360
#coding #neovim #typescript #programming #vim #softwareengineering #codinglife #webdesign #webdevelopment #webdev #javascript #rustlang #rust #twitch #twitchstreamer #programmerhumor #codinghumor #software #softwareengineer #softwaredeveloper #softwaredevelopment
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from ThePrimeagen · ThePrimeagen · 58 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
▶
59
60
Two Simple Steps to go from IDE to Vim
ThePrimeagen
Git's Best And Most Unknown Feature
ThePrimeagen
My Developer Workflow - How I use i3, tmux, and vim
ThePrimeagen
Github Copilot MAKES A CLI GAME IN GOLANG FROM SCRATCH?!?!
ThePrimeagen
I made the greatest tool ever! | tmux & cht.sh & fzf
ThePrimeagen
Is TypeScript (NodeJS) Faster than Go?? | A server comparison
ThePrimeagen
How to make TypeScript Blazingly Fast (JavaScript/NodeJS)
ThePrimeagen
Learn Vim in Less than 2 Minutes
ThePrimeagen
The biggest lie about programming? REACTING to tech twitter
ThePrimeagen
Rust or Go for my next project? WHAT TO CHOOSE? (as a senior intern engineer)
ThePrimeagen
Go is faster than Rust??! Go vs Rust vs TypeScript Servers (as a scientist)
ThePrimeagen
You only Git Merge?!? feat Theo : DevHour #1
ThePrimeagen
YOU DONT UNIT TEST??? DevHour #1 Theo
ThePrimeagen
Tech TikTok - Is this really programming? | React
ThePrimeagen
I am dying
ThePrimeagen
Comparing Rust (Yew) vs TypeScript (React) NodeJS | SSR times
ThePrimeagen
Why I use Vim in 2022
ThePrimeagen
How programming feels
ThePrimeagen
Why I Quit Netflix
ThePrimeagen
Programming on TikTok
ThePrimeagen
If I could give advice to myself when starting as a software engineer
ThePrimeagen
How am I suppose to get a job as a software engineer?
ThePrimeagen
Why do I feel burnt out? (software engineering)
ThePrimeagen
I am done with vim
ThePrimeagen
Maintaining Motivation as a Software Engineer
ThePrimeagen
Bun (TypeScript) is faster than Rust!?!
ThePrimeagen
Go is blazingly faster than Zig?
ThePrimeagen
Facebook Recommends Rust?
ThePrimeagen
5 Things I Hate About JavaScript
ThePrimeagen
Why I Make Content
ThePrimeagen
Is ADHD Bad For Programming?
ThePrimeagen
Vim As You Editor - Advanced Motions P1
ThePrimeagen
How I Would Get My First Job If I Started Over
ThePrimeagen
Vim as your editor - Advanced Motions P2
ThePrimeagen
My Best Decision Professionally
ThePrimeagen
Should you use RUST as your FIRST programming language?
ThePrimeagen
How I Made JavaScript BLAZINGLY FAST
ThePrimeagen
Is JSON Blazingly Fast or...?
ThePrimeagen
Vim As Your Editor - Introduction
ThePrimeagen
Vim As Your Editor - Horizontal
ThePrimeagen
Astro IS SO GOOD
ThePrimeagen
STOP LYING, The truth about Software Engineering
ThePrimeagen
Does Your Editor Matter?
ThePrimeagen
React Is This Fast???
ThePrimeagen
Vim As Your Editor - Vertical Movements
ThePrimeagen
Rust for TypeScript devs : Borrow Checker
ThePrimeagen
Will ChatGPT Terminate Your Job?
ThePrimeagen
0 to LSP : Neovim RC From Scratch
ThePrimeagen
From Meth To Netflix
ThePrimeagen
Faster than your favorite JS framework?
ThePrimeagen
Primeagen Answers the Webs Most Asked Questions for a Software Engineer
ThePrimeagen
This Algorithm is 1,606,240% FASTER
ThePrimeagen
Looking Under the Hood of JavaScript
ThePrimeagen
What Next...Finding a New Job In Software
ThePrimeagen
JSON, I hardly know 'er
ThePrimeagen
RUST Enums ARE Better
ThePrimeagen
CoPilot Review: My Thoughts After 6 Months
ThePrimeagen
How to Vim in 2023: Tips and Tricks
ThePrimeagen
Twitter's Algorithm Has MASSIVE Problems
ThePrimeagen
Rust Foundation IS DOING WHAT????
ThePrimeagen
More on: AI Workflow Automation
View skill →Related Reads
📰
📰
📰
📰
The 5 Levels of Front End Engineering (And Where Most Developers Get Stuck)
Medium · Programming
Browser-Based PDF Editing with Vue 3 and pdf-lib
Dev.to · sunshey
Say Goodbye To Electron?
Medium · Programming
Why Vanilla JS?
In the article below, I am sharing my story of building SaaS product in vanilla js and explaining why I decided to go with this approach.
https://guseyn.com/html/posts/why-vanilla-js.html
Dev.to · Guseyn Ismayylov
🎓
Tutor Explanation
DeepCamp AI