Vim Motions for absolute beginners!!!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so Vim can be divided into three parts first Vim motions Vim motions consist of modes and commands that help developers navigate and edit code more efficiently second the Vim editor this is the actual Vim binary that we can install to load project files and edit them and third Vim plugins Vim functionality can be extended using many Community maintained plugins you can literally turn the Vim editor into Vim as an IDE in this video we will explore Vim motions using Vim motions you can write and navigate through code blazingly fast every popular IDE comes with a Vim plugin so you can open vs code and start using Vim to do that search for the Vim extension inside vs code and install it this enables Vim navigation inside vs code itself Vim comes with three modes normal mode insert mode and visual mode think of these modes as two separate keyboards sitting on top of each other the keyboard on top is normal mode where you type all the Vim commands the keyboard at the bottom is where you actually write code this is called insert mode visual mode works on top of normal mode and helps us visually select and manipulate text visual mode has two different varieties normal visual mode and block visual mode normal visual mode works the same as selecting text with a mouse while block visual mode helps you select text as a block Vim also provides a leader key which helps us add one more layer of shortcuts on top of normal mode however that is for additional personal shortcuts and is not within the scope of today's video there is another special Mode called command mode which helps us give commands to the text editor to save we use the right command with the letter W to set line numbers the set numbers command is used Vim supports thousands of such commands let's open a simple react app and begin navigating the idea is to not lift hands from the keyboard remember everything I am typing is in normal mode so all key events will be treated as commands and new characters won't appear on the screen to navigate up down left and right we don't have to use arrow keys instead we can use h j k and l h and L help us go right and left while J and K help us move down and up respectively these commands can be prefixed with a number typing 5j will move us five times down using W will navigate forward word by word using B will navigate backward word by word this way we will jump to the beginning of every word to jump at the end of a word we have to use the the E key these keys can be prefixed with a number typing 5 W will move us five words forward the dog key helps us jump to the end of the line and the zero key helps us jump to the beginning of the line using coret we jump to the first non-empty character on the line to jump to a specific character on the line we can use the F key in combination with the character where we want to jump so to jump to the next dot we type f followed by dot to jump to the previous dot we type capital F followed by dot next let's see vertical navigation to move one sentence up or down we can use parentheses and to move one paragraph up and down we can use curly braces contrl D and control U help us move up and down half a page at a time to move by a full page we use contrl F and contrl B to move to the start of the page we use 2 * G and and to move to the end of the page we use capital G there are different ways to enter into insert mode in Vim notice the cursor on the screen we may want to insert text at different locations around this cursor if we want to insert text before the cursor we can press the I key on the keyboard and we will be able to insert text before the cursor using the letter A we will be able to insert text after the cursor we can insert text at the beginning of the line by pressing the capital I key on the keyboard and insert at the end of the line using the capital a letter we can insert text after the current line using the letter O and before the current line using capital O apart from the io and a keys we can use the c key to change a word or the S key to replace the current character and enter into insert mode using the keys y and p we can copy and paste text we can copy a whole line using YY and paste it using the letter P it is also possible possible to copy text between parentheses curly braces or square brackets using Yi and the respective curly brace square bracket or parenthesis to copy text including curly braces we can use y a and curly brace let's paste a few lines now by pressing U we will undo the last change let's Undo It multiple times by pressing U several times if we want to redo it we can press controlr and we can redo all the changes we can type the key D and either w s or P to delete a word sentence or paragraph We can delete a whole line by typing D twice it is also possible to delete up to a specific character by pressing DT and a particular character the dot is the repeat key we can repeat any operation performed in normal mode Let's perform the change word operation by typing c i and W this stands for change inner word now we can go to any word and repeat the operation by simply typing the dot key we can search forward by typing a forward slash and the search term this will match the first result forward from the cursor position we can iterate on search results forward by typing the N key on the keyboard we can iterate backward by typing the capital N letter we can search forward for the word under the cursor by typing the star key on the keyboard we can search for the current word backward by pressing the hash key marks in Vim are like bookmarks to Mark a position with the letter A we can type M and the a key this action bookmarks the position under the letter A now if we move around and want to return to the bookmark we can type the back tick character and the name of the bookmark Vim has lots of predefined bookmarks and two essential bookmarks are available first if we want to toggle between the last two visited places we can type back tick twice and we will toggle between the last two positions second if we want to visit the position where the last editing happened we can type back tick and the dot key we will cover the remaining Vim features such as folding indenting and macro recording in the next video If you enjoyed this video please give it a thumbs up and subscribe
Info
Channel: Dispatch
Views: 105,304
Rating: undefined out of 5
Keywords: neovim, vim, vscode, tmux, vim motions, code editing, linux
Id: lWTzqPfy1gE
Channel Id: undefined
Length: 7min 25sec (445 seconds)
Published: Sat Jan 27 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.