In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to use Vim", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use Vim" this article.
Installation
You can install Vim in Ubuntu using the following command:
Sudo apt-get install vim
If you are already interested in some plug-ins, use the following command:
Sudo apt-cache search vim
This command will give you a long list of packages related to Vim. Among them, there are tools for different programming languages, plug-in managers, and so on.
In this series of tutorials, I will use the latest version of Vim on Ubuntu. Of course, you can also use any other version.
Warm up
Enter the vim command on the terminal and you will see a great welcome interface.
I saw the line "Help poor children in Uganda!" in the welcome screen. Did you get it? )
If you've never used Vi or Vim before, you probably don't even know how to quit it. Yes, it's true. Any keyboard shortcuts you use will lose their original effect in Vim. (translation note: there is a joke circulating on the Internet-"how to create garbled code" and "Let beginners quit vi")
First of all, to use any imperative function, such as save or exit, you have to type a colon (:). Save is: W and exit is: Q. If you want to exit without saving the file, use the forced exit command: Q!. The great thing about Vim is that you don't have to type individual commands separately, in other words, if you want to save and exit, you can just use: wq.
Now, let's exit Vim and open another text file. To do this, you simply add the name of the file you want to edit to the command:
Vim [text file name]
In general, when you open a text file, you will be in view mode. This makes Vim unique and initially confusing. Vim mainly consists of two modes: view mode and edit mode. The view mode is used to view the content and use some commands. To enter edit mode, simply press I to insert or a to add. To return to view mode or perform imperative operations, press the Escape key. The only difference between inserting and adding is whether you want to enter edit mode and enter text before or after the cursor position. If you want to understand thoroughly, you should try it yourself. My advice is to use add only at the end of the line and insert at other times.
(translation note: the original text of "View Mode" in this paragraph is "visual mode" and is suspected to be "view mode". You can view the text in this mode, but you cannot edit it. And "visual mode" is a kind of editing mode, you can press the v key to enter, and then you can use the direction key to start the selection from the current cursor position, and display it with a negative visual effect, usually you can press y to copy, press d to cut and other operations. In addition, the language of the author of this article is not standard, according to Vim's own language, the so-called "view mode" here should be called "normal mode", "editing mode" should be called "insert mode", but the meaning is the same. )
To move the cursor through the text, you can usually use the arrow keys on the keyboard, which take effect in both view mode and edit mode. However, a true purist will tell you to use the buttons h to the left, j to the down, k to the up, l to the right (in view mode).
Now that you know how to and simply control Vim, let's go a little deeper.
Some simple commands
Now that you are familiar with switching between normal mode and insert mode, here are some commands that can be used in normal mode:
X: delete a character
U: undo an operation (equivalent to Ctrl+z)
Dd: delete a line of content
Dw: delete a word
Yy: copy a line of content
Yw: copy a word
P: paste a line or word that was previously deleted or copied
E: skip to the next word (LCTT: suffix) (faster than simply using direction keys)
R: replace a letter (press r, release, and then press the new letter)
Of course it's more than that, but that's enough for now. If you master all of the above, you will be able to use Vim smoothly.
For those who want to know more, I would like to mention one more thing. You can add a value before any of these commands, and the command will be repeated the corresponding number of times. For example, 5x will delete 5 letters in succession on the current line, while 3p will paste 3 times.
Advanced command
Finally, as an encouragement and example of your own continued exploration, here are a few advanced and commonly used commands:
/ what is searched: search for specific content in the article
: sp text file name: split the screen horizontally into the upper and lower halves, and the new file is displayed in the other half. To switch focus on both sides, you can use the Ctrl+w shortcut key.
Vsp text file name: same as above, but split the screen vertically
Ctrl+Shift+C and Ctrl+Shift+V: copy and paste text in the terminal
:! Command name: run terminal commands outside Vim in Vim and send them directly to shell. For example:! Ls will display the files in your current directory without exiting the editor.
The above is all the contents of this article "how to use Vim". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.