This year, I am going to explore and learn the basics of vim. Each day, I aim to learn a few vim commands and post them as a series of blog articles.
Day 1 - Installation, Navigation & How to quit vim
Installation
check if it is already installed? vim --version or install it using the following command if you are using ubuntu:
sudo apt install vim
How to quit?
q!- Quit without savingw- Save Changeswq- Save & QuitZZ- Faster Save & Quit
Modes
I’ve explored four modes so far:
- Normal Mode
- Insert Mode
- Visual Mode
- Ex Mode
Step 1: Get rid of Arrow Keys and Mouse
Stop using Arrow keys & mouse. In normal mode, navigate using the following:
h- leftj- down (imaginejis an arrow pointing downwards)k- topl- right
Step 1.5: More about Navigation
^Y- Scroll Up a little bit.Ctrl + Y^E- Scroll Down a little bit.Ctrl + E^B- Scroll Up a screen.Ctrl + B- ^F - Scroll Down a screen.
Ctrl + F
Step 1.8: A Final Touch
gg- Go to top of the fileH- move the cursor high i.e. top of the screenM- move the cursor to the middle of the screenL- move the cursor to the bottom of the screenG- Go to the bottom of the file.
That’s it, for tonight. Let’s practice this for a day and put these commands in muscle memory!
Vim Resource
- Recommended Book: Practical Vim: Edit text with the speed of thoughts by Drew Neil
- Video: https://www.youtube.com/watch?v=E-ZbrtoSuzw
Wasi's Log