Vim/Vi tutorials For beginners

Most of the people tired off using Vim, and I do faced the same problem. But, in the actual case, it’s not a big deal. The thing is, we should understand the basics to use that.

First, Launch your fellow terminal then,

Open any file, that you wanted to edit. In my case -I’m opening main1.java by using the below command

To edit the file or to insert any characters in that file, we need to get into- “INSERT mode” by pressing the

Now, edit whatever u need to, by moving the cursor forward and backward by using your arrow keys, and deleting the contents using your backspace key

Now, its time for saving the contents…nooo don’t use ctrl+s -that fellow won’t work here.., Here its about what mode we are in -Now, we are in the INSERT mode-So, we have to get into command mode to make our command to work, For that, press

Now It’s time to exit, right? then press

To copy and to paste the things inside the terminal, we use a different terms -which is “yank” and paste.

Note that “yank” will copy the contents to the terminal’s own clipboard -it won’t let you copy outside ( for copying it to the system’s clipboard — read about +clipboard )

For yank, go to “VISUAL LINE Mode” by pressing the

So, that we shall notice terminal showing us the term “visual mode” in its bottom. Now just simply drag the mouse or use down arrow to select mulitple lines inorder to do some operations. Now , yank by pressing the

Some Shortcuts will make this process cool. They are

Now let’s move on to vimdiff , with the following command to compare the files where we use this more often to resolve the merge conflict.

From the above pic, it is sure that we can easily find out the differences between the files , pink spots are for the modified area, and the blue is for the missed out lines ( either removed or added)

Shortcuts to access this window

Now, to resolve the change conflicts -just move the cursor where you wanted to change and use

ie.,
If the cursor is on the line where the pink highlights are depicted on the first window for instance,

For your convenience, better use simple “yank” and paste as I told earlier. And at last, don’t forget to save and close which is

And there are still many features available in the vim, but what I told now is more enough to manage the files in the vim…
Have a nice day!!

Also Clap me on my Medium Page:
https://medium.com/@rdharan/vim-basic-cheatsheet-for-beginners-297190fc8331

原文链接:Vim/Vi tutorials For beginners

© 版权声明
THE END
喜欢就支持一下吧
点赞14 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容