In Day 1, we learned how to install vim, we also learned the basic navigation shortcuts of vim. Today, we will learn a few more basic vim commands.
some more navigation to ease up scrolling
^U– Go Up Half a Page (CTRL + U)
^D– Go Down Half a Page (CTRL + D)
zt– Put Cursor to the top
zb– Put Cursor to the bottom
- zz – Put Cursor to the middle of the screen
Introducing Help – Your best vim buddy
In Normal mode you can use a command to get help. Just type
:h It will open up vim’s help text. You can even search for specific help by specifying what you need, for example:
Vim’s help text is rich & tidy. It will help you to get a good grasp of vim’s philosophy. I highly recommend you to read through it.
Now, let’s learn a few vim operators. Operators are more like commands that you can apply to objects. Below is the list of most commonly used vim operators:
y– Yank: copy the current object in the cursor position (An object could be word, line, block, etc)
d– delete: deletes the current object in the cursor position
p– Paste: paste the yanked/deleted objects from the buffer
x– removes the objects in the cursor position.
c– Change: deletes the object and puts it into insert mode so that you can type.
We don’t have to memorize anything! Notice how the letter speaks the operation! For example, want to change something? use
c. To delete a word we will have to use
d, Make sense?
That’s it for today! Let’s practice all these commands and get used to them.
🍪 Vim Cookie #1
Try the following in normal mode! Do you see anything familiar? 😉