Vim tutorial for beginner! (Part 1)
What's up guys!
You might ever heard of Vim, it is a pretty amazing and powerful (but sometimes a nightmare with other people) text editor. So, in this tutorial, you will learn about how to use Vim properly and without a hassle! :D
This is the part 1 of this tutorial series. I will also do the part 2 if I have enough time and motivation!
Without further ado, let's get started!
Installation
First, of course, we need to install Vim first, I'm using Neovim for this tutorial but you can also use pure Vim for this!
To install Neovim on your Linux system, you can simply use a package manager (like apt or pacman):
sudo apt-get install neovim
sudo pacman -S neovim
With MacOS, you do the same with Homebrew:brew install neovim
In cases that you are using Windows, check out this.
Ok, so your Neovim has been installed, let's open it up! To open Neovim, make sure to type nvim
( Yes, nvim
, not neovim
).
You will be greeted by this:
If you see it from your Terminal, congratulations! You have just installed and start Neovim correctly! :D
Now, our text editor is ready and let's dive into Vim tutorial!
Modes in Vim
In Vim, there are 2 basic modes, insert
and normal
. insert
mode is the mode thats allows you to enter code like you do in a normal text editor, and normal
mode is the mode that you work with Vim key bindings and commands, you can only see your code (only see and cannot edit) in this mode.
Now, in default, we are in the normal
mode, to change mode in Vim, use Esc
for normal
mode and i
for insert
mode.
Let's move on!
Basic movements in Vim: h, j, k, l
In Vim, we use h
, j
, k
, l
key to move the cursor instead arrow key. The key movement are:
h
- leftj
- downk
- upl
- right
Navigate text in Vim: w, e, b
To navigate text in terms of words, we will use w
, e
, b
key!
w
moves to the start of the next word, e
moves to the end of the word, and b
moves to the beginning of the word!
Number powered movements
Vim doesn't limited to individual keys in moving, you can mix a number with a movement key to make works better. e.g. 3w
is the same as press the w
key 3 times, and 9b
is same as press the b
key 9 times.
Insert text repeatedly
If you need to type a specfic number of a words e.g. 30 s
words, you can do it by typing 30is Esc
. You save your time! :)
Find words with f
and F
To finds the occurence of the next or previous character, we will use f
and F
e.g. fq
finds the next q
character and vice versa, Fq
finds the previous q
character.
You can combine f
and F
with a number before the key, for example, 3fq
finds the next 3rd occurence of q
.
Please don't post "parts" or a series of posts to the Tutorials board. Write a good tutorial in one post and post it. Otherwise, it can be considered cycle farming/squeezing. This is just a warning.
@Vandesm14 I'm sorry, it's pretty late when I write this post (9 o'clock, I think) and it was 9:30 when I done, so I need to set the tutorial to parts. I already have plan to write all the stuff of Vim in one single post. But it 's 11:07 PM in my country in the time I write this reply...
Edit: Maybe I will fix the title and edit the post to make it a single tutorial post if I have time tomorrow.
I think you accidentally warned me... I haven’t been on repl for months. @Vandesm14
@Vandesm14 Hi, would you like to work on a project with, me srry for contacting you this way, it was the only way I could find you, also I also found out about you, because you unlisted my post, but anyways would you like to work a project together?
@Wumi4 Sure, that's fine.
@MATTHEWBECHTEL I apologize if I accidentally warned you. You we're warned for asking for upvotes on one of your posts/comments. Due to the way the moderation system works, I am not able to go back and take a look at the evidence as it's most likely been deleted. I apologize for the inconvenience.
Just hopping on for future reference. Is there a tutorial that would be long enough to warrant multiple parts, like codelng’s C tutorial series? Stuff like that? Or how to build a cdn?
@Vandesm14
@Highwayman It really depends. From what I know right now, as long as your tutorial covers a whole subject in one go (sort of). It's hard to explain directly, but if you mention me either on the post or in a comment, I'd be happy to take a look at your tutorial for you!
@Highwayman I think the CDN was premature, CWars was a little bit of cycle framing (Could have been done in three)
Uhm sure lol. @Vandesm14
Ok, cool, so then basically just ping a mod for evaluation if you really wanna then ok cool.
@Vandesm14
Oh? I thought the split up made sense, I’m kinda surprised about Cwars
@CodeLongAndPros
@Highwayman Yes
Awesome, thanks 👍🙂
@Vandesm14