Vim As Your Editor - Horizontal

ThePrimeagen · Intermediate ·💻 AI-Assisted Coding ·3y ago

Key Takeaways

The video demonstrates Vim as a primary editor, showcasing various tools and techniques such as Vim motions, buffer management, and plugin customization, with tools like Vim, neovim, Rust, Lua, Vim API, netrw, telescope, and Harpoon.

Full Transcript

all right so you've been using Vim now you're feeling pretty smooth but you want to step that game up right you want to go from that canola oil to the coconut oil you want to be as smooth and creamy as Vim diesel but maybe you're not maybe you're still struggling maybe you still got the training wheels on well then check out this video this will be the intro you need to get good see the thing is when you manage a multi-billion dollar startup you don't have time for a program loading up okay you're all them all speed all coconut oil now here's the thing personally I use it on all my personal projects I program exclusively with them and you know what that means so yes that means I do write rust in neovim tell me your sex however without telling me your sex ever all right so the first thing I want to start off with is a couple new motions for you this is going to really help you move horizontally and if this does not make your life feel like it's covered in Dripping in coconut oil I don't know what will because after this lesson you should be able to be significantly faster at using Vim motions so first off some basic movements underscore goes to the beginning dollar sign goes to the end zero goes to the beginning character like the zeroth one so I can mix those just like we did before we can do D dollar sign which will delete from your cursor all the way to the end but sometimes you want to be able to move around in the line to a specific character so let's take a look at this first opening parenthesis right here if I wanted to jump to it I could use f opening parentheses F goes forward to the character you say let's go back I can also do T same character and this jumps up two but not on the character you specify if you wish to repeat it you can use comma and semicolon comma goes backwards semicolon goes forward here's a good example let's go like this Fe and then as I use semicolon and you can see that I'm walking forward as I press comma you can see I walk backwards but let's go the other direction if I wanted to jump back to the equal sign I can press capital f equals and it'll jump back to the equal sign exact same thing with t capital T equals we'll jump to the equal sign but not on top I've actually found myself using these quite a bit and I remember that time when I first discovered this this was just like it was just such an amazing feel knowing that I can jump through the lines like that now if you remember from the previous video we did talk about the anatomy of a motion a command can be used along with a count and emotion so let's jump back here if F opening squirrely brace jumps to the squirrely brace that means d f opening parentheses I can never say those it will delete from my character up to and including the opening parentheses let's undo that let's walk back that means DT uh opening parentheses will delete up to it but not including it my cursor is now on top of it same thing with yank YT opening parentheses will yank up in two and of course the GT opening parentheses will do the same thing this of course works the other direction if I go V capital F equal sign I will jump back and highlight same thing with yank as well yank capital f equals sign I just yanked all that now I can paste all of it in so a big thing to start seeing here is that it always goes command count motion so just to kind of show you one more thing I can d 2 F opening parenthesis notice that it deleted past that first one and to the second one now I don't often do that level but you could you actually could so just don't forget the anatomy of emotion a couple more capital I will go to the beginning of the line but in insert mode capital A will go to the end of the line but in insert mode now this should be pretty familiar with how I and a work it's just the bigger version of it lastly these two are just the most amazing oh will make a new line and go into insert mode whereas capital O will make a new line above your cursor and then go into insert mode yes I do use Dvorak since I wanted to show you today because I really just want you to focus moving in that line yes vertical movement will still be a bit of a pain if you haven't done your own research I promise I will help you next lesson on that all right I would like to switch gears and go from talking about some Vim motions to talking about Vim the editor this way you can have a better understanding as you jump into the Vim editor itself now of course I've made the assumption that you have looked at my Vim RC introduction video I'm not going to be talking about the vimrc I'm not going to be talking about how to install plugins or how to write small scripts this will be primarily focused on Vim itself if you wish to go look at that go down hit the Subscribe button on your way down and check the link in the description all right so let's just talk about Vim in general so what you're seeing right now is a buffer a buffer simply is something that contain text it can has some various options like this one since it's a view of the file system I can't just come in here and press o and start editing instead oh will take me to to a file now this buffer is contained in a window so let me show you kind of what that means what I'm going to do is I'm going to open the same window several times and I'm going to go down here and I'm going to type in Lua Vim API dot neovim get current window and when I print that out it says 125. I'm going to jump over to the next one and I'm going to do it again it says 124. 123 120. you can see each one along the way but now let me get the buffer instead right so there we go 18. 18. 18 . it's all the same buffer because it's actually opening the same place in my file system so if this was individual files it would be the same thing so let's go into server and now I'm going to re-execute the buffer the buffer is now 10 but the window is still the same window it was in the beginning 125. if I hop over here the buffer is still what it was 18 if I go into server it also will be 10 now so do you understand that a window contains a buffer a buffer is some representation of the file below it or should I say in memory representation all right so let's do something cool here to kind of really lay that down what I'm going to do is I'm going to add a new file in here new file.ts I'm going to save it and now I'm going to go back to that buffer notice that it updated in every single place because these buffers are all the same buffer so even though I navigated away and came back that buffer stayed in memory so this is a really good mental model to have so when someone says buffer what they mean is a in memory representation of something that's like saved on the disk or some sort of temporary item that when you leave it it'll be gone it's some sort of visual representation a window contains a buffer that way when I'm right here I can still switch between a bunch of files because it's a single window that I'm changing out all the different files on or buffers now I'm going to make the assumption that you actually have watched that vimrc video and you have installed a couple plugins yourself you kind of have a general feel I'm going to give you some basic navigation tips now with Vim all right so let's open up Vim if you were to type in Vim period what happens is it actually opens up that current directory and shows you it now yours will look a little bit different if you have not kind of edited your netrw experience mine looks like this netrw allows you to do your basic file system manipulation so that means I can literally just delete that boom it's gone you can obviously open up files on here so I can just open up the TS config there you go that's a big old TS config and of course you can open up netrw anytime you want by typing in sec bang now don't get too excited Arch users okay I know you just saw it you saw it you wanted it now me personally I don't like a file Tree on the side ever so I usually open it up with X I kind of in like a one view monogamous buffer kind of individual I just go one at a time now as far as navigation of files Go you could use your you know your J your K walk around in here walk to the index open it up and there we go we've made it to the file but that is like pretty dang inefficient so I have a remap leader PV we'll just simply re-open up X so I wouldn't really use a tree view to be able to do all my navigation what I actually usually do is I have something called telescope if you're not familiar with telescope it was created hand crafted artisanally by TJ and now pretty much maintained by Connie the legend this allows you to be able to do fuzzy fighting and not even just over files you can do it over get branches you can make your own custom fuzzy find lists you can even make your own custom algorithms for going over items in a list so think about it as like FC F but a bit more customizable to the point where FCF is even usable in telescope and of course my other way that I use navigation within Vim is with Harpoon Harpoon effectively is allowing you to have a few files be sticky files allowing you to just go back there really really quickly so if you remember my list my list had these three on here so that means if I press a button I can go to one of the files another button I can go to that other file I can go back to this one and I can cycle between them really really fast I've obviously set up my own remaps that are comfortable for me you can set up your own the readme is obviously filled the same way as telescopes readme is filled with all the things you need but really kind of diving into navigation will be very helpful for you so make sure you spend some time and you find the right plugins for you a general rule of thumb that I have when it comes to installing plugins is that I find a need so obviously a clear need is you want a fuzzy finder navigating a project with just a tree view would be a nightmare so I go and I find that thing and if it doesn't exist I create that thing now almost always it exists fuzzy finder telescope FCF you can actually use either or Harpoon is something I created because I couldn't find what I wanted and that's the beauty of them is that you get to choose what you want to customize versus what you want to go and install you get to cran craft the shortcuts and what plugins you use to be the environment you want it to be and I really just find it to be an overall really nice experience so I hope in this week's lesson you've taken away two things a there's a lot more motions you can really get fast and B you need to start thinking about how do you want to customize your Vim experience how do you want to be able to interact with Git find files open files maybe harpoon's the thing you want to do maybe you want to learn about marks but either way there's a lot of knowledge and hopefully this week you get even faster even creamier even smoother than you've ever been because the Motions that I showed you should make you a lot faster now if you like this series just hit that subscribe button down below there's going to be a few more after this that are going to go over some Vim specific stuff and of course some more motions to make you better and creamier at navigating them and again if you haven't done the vmrc video go do it because it'll be a lot easier consuming this video series thank you for watching the name is the prime machine

Original Description

Coconut Oil smoothness is now in your future. get good at these and i promise you will feel faster than you currently do with a mouse. You can also gently place VSCode in the garbo. BEFORE YOU CLICK THOSE LINKS, like the video, hit that sub button. it really helps. the algo really loves to be edged. ### VIM RC https://www.youtube.com/watch?v=x2QJYq4IX6M ### Vim As Your Editor Part 1 https://www.youtube.com/watch?v=X6AR2RMB5tE ### 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 #vim #programming #softwareengineering
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from ThePrimeagen · ThePrimeagen · 40 of 60

1 Two Simple Steps to go from IDE to Vim
Two Simple Steps to go from IDE to Vim
ThePrimeagen
2 Git's Best And Most Unknown Feature
Git's Best And Most Unknown Feature
ThePrimeagen
3 My Developer Workflow - How I use i3, tmux, and vim
My Developer Workflow - How I use i3, tmux, and vim
ThePrimeagen
4 Github Copilot MAKES A CLI GAME IN GOLANG FROM SCRATCH?!?!
Github Copilot MAKES A CLI GAME IN GOLANG FROM SCRATCH?!?!
ThePrimeagen
5 I made the greatest tool ever! | tmux & cht.sh & fzf
I made the greatest tool ever! | tmux & cht.sh & fzf
ThePrimeagen
6 Is TypeScript (NodeJS) Faster than Go?? |  A server comparison
Is TypeScript (NodeJS) Faster than Go?? | A server comparison
ThePrimeagen
7 How to make TypeScript Blazingly Fast (JavaScript/NodeJS)
How to make TypeScript Blazingly Fast (JavaScript/NodeJS)
ThePrimeagen
8 Learn Vim in Less than 2 Minutes
Learn Vim in Less than 2 Minutes
ThePrimeagen
9 The biggest lie about programming?  REACTING to tech twitter
The biggest lie about programming? REACTING to tech twitter
ThePrimeagen
10 Rust or Go for my next project? WHAT TO CHOOSE? (as a senior intern engineer)
Rust or Go for my next project? WHAT TO CHOOSE? (as a senior intern engineer)
ThePrimeagen
11 Go is faster than Rust??!  Go vs Rust vs TypeScript Servers (as a scientist)
Go is faster than Rust??! Go vs Rust vs TypeScript Servers (as a scientist)
ThePrimeagen
12 You only Git Merge?!? feat Theo : DevHour #1
You only Git Merge?!? feat Theo : DevHour #1
ThePrimeagen
13 YOU DONT UNIT TEST??? DevHour #1 Theo
YOU DONT UNIT TEST??? DevHour #1 Theo
ThePrimeagen
14 Tech TikTok - Is this really programming? | React
Tech TikTok - Is this really programming? | React
ThePrimeagen
15 I am dying
I am dying
ThePrimeagen
16 Comparing Rust (Yew) vs TypeScript (React) NodeJS | SSR times
Comparing Rust (Yew) vs TypeScript (React) NodeJS | SSR times
ThePrimeagen
17 Why I use Vim in 2022
Why I use Vim in 2022
ThePrimeagen
18 How programming feels
How programming feels
ThePrimeagen
19 Why I Quit Netflix
Why I Quit Netflix
ThePrimeagen
20 Programming on TikTok
Programming on TikTok
ThePrimeagen
21 If I could give advice to myself when starting as a software engineer
If I could give advice to myself when starting as a software engineer
ThePrimeagen
22 How am I suppose to get a job as a software engineer?
How am I suppose to get a job as a software engineer?
ThePrimeagen
23 Why do I feel burnt out? (software engineering)
Why do I feel burnt out? (software engineering)
ThePrimeagen
24 I am done with vim
I am done with vim
ThePrimeagen
25 Maintaining Motivation as a Software Engineer
Maintaining Motivation as a Software Engineer
ThePrimeagen
26 Bun (TypeScript) is faster than Rust!?!
Bun (TypeScript) is faster than Rust!?!
ThePrimeagen
27 Go is blazingly faster than Zig?
Go is blazingly faster than Zig?
ThePrimeagen
28 Facebook Recommends Rust?
Facebook Recommends Rust?
ThePrimeagen
29 5 Things I Hate About JavaScript
5 Things I Hate About JavaScript
ThePrimeagen
30 Why I Make Content
Why I Make Content
ThePrimeagen
31 Is ADHD Bad For Programming?
Is ADHD Bad For Programming?
ThePrimeagen
32 Vim As You Editor - Advanced Motions P1
Vim As You Editor - Advanced Motions P1
ThePrimeagen
33 How I Would Get My First Job If I Started Over
How I Would Get My First Job If I Started Over
ThePrimeagen
34 Vim as your editor - Advanced Motions P2
Vim as your editor - Advanced Motions P2
ThePrimeagen
35 My Best Decision Professionally
My Best Decision Professionally
ThePrimeagen
36 Should you use RUST as your FIRST programming language?
Should you use RUST as your FIRST programming language?
ThePrimeagen
37 How I Made JavaScript BLAZINGLY FAST
How I Made JavaScript BLAZINGLY FAST
ThePrimeagen
38 Is JSON Blazingly Fast or...?
Is JSON Blazingly Fast or...?
ThePrimeagen
39 Vim As Your Editor - Introduction
Vim As Your Editor - Introduction
ThePrimeagen
Vim As Your Editor - Horizontal
Vim As Your Editor - Horizontal
ThePrimeagen
41 Astro IS SO GOOD
Astro IS SO GOOD
ThePrimeagen
42 STOP LYING, The truth about Software Engineering
STOP LYING, The truth about Software Engineering
ThePrimeagen
43 Does Your Editor Matter?
Does Your Editor Matter?
ThePrimeagen
44 React Is This Fast???
React Is This Fast???
ThePrimeagen
45 Vim As Your Editor - Vertical Movements
Vim As Your Editor - Vertical Movements
ThePrimeagen
46 Rust for TypeScript devs : Borrow Checker
Rust for TypeScript devs : Borrow Checker
ThePrimeagen
47 Will ChatGPT Terminate Your Job?
Will ChatGPT Terminate Your Job?
ThePrimeagen
48 0 to LSP : Neovim RC From Scratch
0 to LSP : Neovim RC From Scratch
ThePrimeagen
49 From Meth To Netflix
From Meth To Netflix
ThePrimeagen
50 Faster than your favorite JS framework?
Faster than your favorite JS framework?
ThePrimeagen
51 Primeagen Answers the Webs Most Asked Questions for a Software Engineer
Primeagen Answers the Webs Most Asked Questions for a Software Engineer
ThePrimeagen
52 This Algorithm is 1,606,240% FASTER
This Algorithm is 1,606,240% FASTER
ThePrimeagen
53 Looking Under the Hood of JavaScript
Looking Under the Hood of JavaScript
ThePrimeagen
54 What Next...Finding a New Job In Software
What Next...Finding a New Job In Software
ThePrimeagen
55 JSON, I hardly know 'er
JSON, I hardly know 'er
ThePrimeagen
56 RUST Enums ARE Better
RUST Enums ARE Better
ThePrimeagen
57 CoPilot Review: My Thoughts After 6 Months
CoPilot Review: My Thoughts After 6 Months
ThePrimeagen
58 How to Vim in 2023: Tips and Tricks
How to Vim in 2023: Tips and Tricks
ThePrimeagen
59 Twitter's Algorithm Has MASSIVE Problems
Twitter's Algorithm Has MASSIVE Problems
ThePrimeagen
60 Rust Foundation IS DOING WHAT????
Rust Foundation IS DOING WHAT????
ThePrimeagen

The video teaches viewers how to use Vim as their primary editor, showcasing various tools and techniques to improve navigation and productivity. By mastering Vim motions, buffer management, and plugin customization, viewers can become more efficient in their coding workflow. The video also highlights the importance of practice and provides resources for further learning.

Key Takeaways
  1. Use underscore to move to the beginning of a line
  2. Use dollar sign to move to the end of a line
  3. Use zero to move to the beginning character of a line
  4. Use f to jump to a character
  5. Use F to jump forward to a character
  6. Open Vim and navigate through the file system using basic motions
  7. Use the Vim API to get the current window and buffer
  8. Switch between buffers in a single window
  9. Update buffers in real-time even when navigating away and coming back to them
  10. Type 'Vim.' to open current directory
💡 Mastering Vim motions and buffer management can significantly improve coding productivity and efficiency

Related AI Lessons

Up next
Azure Security Priorities for 2026: Identity, Governance, AI Security & Zero Trust
Valto Microsoft Specialists
Watch →