Vim
Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient. Let's have a demonstration of it.
Getting Start to use vim
Simply type
And you can see an interface like this, this is the UI when you start vim
by not specifying a file name.
Now type :q
to quit Vim, you will find that when you type :
your cursor will be redirected to the bottom of the window and then you can type commands in the input line. Then you will be back to the Linux shell.
Vim is a highly hackable and customizable text editor, so you can make your own configuration to this. Here is my Vim, I try to make it concise.
Now let us play around with Vim by editing a file. You should first cd
to a directory you like to save the file that you will edit with Vim. Then type:
This command will lead you to use Vim to create a file named helloworld.py
and edit it at the same time. You are now able to edit the Python code (or script) with Vim. But take your time, you are now trying to type something but you find no response (or get some wired responses).
Now press i
in the keyboard. Then you will find there is something like that in the bottom-left corner of the window. This means you are in INSERT
mode, which means you can insert (type) anything in the buffer (file). Which looks like that. (You may not find the red bar but it is Okay when you notice that some text like -- INSERT --
)
Then type a simple hello-world snippet in the file you are editing, if you are not familiar with Python, please refer to the following code.
Since you finish editing the script, simply press Esc
key on the keyboard which is always located at the upper-left corner of the keyboard. You will notice that the -- INSERT --
disappears. Now you are in the NORMAL
mode. In this mode, you can navigate the cursor around the text, change a specific character, increase a number and play some magic.
Notice that almost all keys in the keyboard are mapped to a command or shortcut when you are in NORMAL
mode. What's more, you can even define more keys or keys-combination to do some other functions, like that: (which means when I press control
+ t
, Vim will open a new Terminal window split in the downside of the current window)
I am used to mapping jk
to Esc
, which means when I quickly type j
and then k
, Vim will press for me Esc
to back to the normal mode.
Vim has had a horrible learning curve since you started to learn it. It will take nearly 2-3 weeks using it typing codes and texts to make it as your first editor. After that, you can configure it to make it adapt to you. Once you have managed it, you will find it is so handy.
By the way, you can install Vim plugins into your favorite IDE, which means it can be used not only in the command line. Since Vim has been developed for over 40 years, the command and shortcuts are not changed, which means once you learn it, you can use it in your lifetime.
Vim Tutor
One of the easiest ways to learn Vim is by reading the official documentation. Typing
Try to play it around, try to switch your code (text) editor to Vim in the next few weeks.
👍 Goal: Finish
vimtutor
Lesson 1-4This part will be demostrated on the class.
Vim Cheat Sheets
Last updated