Hello there Nullbytes,
In my previous tutorial found here,
https://null-byte.wonderhowto.com/how-to/vim-as-ugly-as-is-fast-0168012/,
I wrote about using normal mode.
Today we will go trough the basics of using the Normal Mode.
The things we will be discussing:
- Making VIM more sublime
- Navigation
The point of todays tutorial is to get you to the point where you are faster using VIM than when using Gedit or Nano.
Note that VIM has a LOT more potential.
First we need to make sure we are in Normal Mode, press Esc to do so if you are in Insert Mode.
Making VIM More Sublime
When you go straight to Insert Mode in VIM to write your code, you'll notice it doesn't auto-indent or highlight syntax.
Luckily there is a way to include these options (and a lot more as well).
To set auto-indent in VIM, first, be sure that you are in Normal Mode and then type: :set autoindent, or if you are coding C or C++
:set cindent.
To highlight syntax simply type: :syntax on.
To set numbers type: :set number.
Navigation
There are a few ways to navigate in VIM:
- Using the arrow keys (bad habit)
- Using h, j, k and l
- Alternative options
We will be using h, j, k and l because of the positions of our hands and the fact that there are cool tricks to them.
To navigate using h, j, k and l:
- h for left
- j for down
- k for up
- l for right
Now when constantly tapping j or k to navigate, this starts to feel very inefficient.
Whenever something feels inefficient in VIM, believe me when I say:
There is a better way to do it.
Instead of tapping 'j' 5 times, tap '5' then 'j'.
This can be done with any integer.
Another way to navigate is to navigate trough words instead of single characters.
- To navigate to the first letter of the next word, press w
- To navigate backwards, press b
- To navigate to the last letter of the next word, press e
Note that again you can combine this with integers.
So to navigate 2 words press '2', then 'w'.
Same for 'b' and 'e'.
That will be it for today, I've decided to make this a serie.
Next tutorial we will be discussing search, copy & past, and a few other tricks.
Feel free to post feedback, I know there is a LOT LOT LOT LOT that I've not included here, but I want to stick with the basics first and later the more 'advanced' features of VIM.
P.s. VIM has a built in help manual that is really well written.
To use it, type: :help
Just updated your iPhone to iOS 18? You'll find a ton of hot new features for some of your most-used Apple apps. Dive in and see for yourself:
Be the First to Comment
Share Your Thoughts