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.
And you can see an interface like this, this is the UI when you start
vimby not specifying a file name.
~ VIM - Vi IMproved
~ version 8.1.2269
~ by Bram Moolenaar et al.
~ Modified by [email protected]
~ Vim is open source and freely distributable
~ Help poor children in Uganda!
~ type :help iccf<Enter> for information
~ type :q<Enter> to exit
~ type :help<Enter> or <F1> for on-line help
~ type :help version8<Enter> for version info
:qto 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
cdto a directory you like to save the file that you will edit with Vim. Then type:
-> vim helloworld.py
This command will lead you to use Vim to create a file named
helloworld.pyand 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).
iin the keyboard. Then you will find there is something like that in the bottom-left corner of the window. This means you are in
INSERTmode, 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
Esckey 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
NORMALmode. 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
NORMALmode. What's more, you can even define more keys or keys-combination to do some other functions, like that: (which means when I press
t, Vim will open a new Terminal window split in the downside of the current window)
nnoremap <C-t> :sp<CR><C-w><C-j> :term<CR>
I am used to mapping
Esc, which means when I quickly type
k, Vim will press for me
Escto 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.
Leaning curves meme
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.
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
vimtutorLesson 1-4This part will be demostrated on the class.
Operations & Repeatitions
Yank(Copy) & Paste
Marks & Macros
Last modified 1yr ago