Vim simple tutorial (1)

Source: Internet
Author: User
Vim simple tutorial (1) I used vim a long time ago, but the most basic operations would be performed when the level is good. And often hesitate to jump to the Emacs camp. after all, the legendary Emacs is so powerful that it can kill everything in seconds. But it seems that Emacs is more difficult to learn. In the end, let's decide to join vim...
Vim simple tutorial (1)
I used vim a long time ago, but the basic operations would be the best if I had a good level of food. And often hesitate to jump to the Emacs camp. after all, the legendary Emacs is so powerful that it can kill everything in seconds. However, Emacs seems to be more difficult to learn. In the end, let's decide to join vim. I accidentally found the VI iMproved book written by Steve Oualline. after reading it, I really thought I was a beginner. My blog series is actually my notes for studying VI iMproved. I hope you will be able to learn VIM.
Www.2cto.com
(Vim and Emacs seem to be a little different. it is difficult to learn another one after learning one. Therefore, if you decide to learn vim, don't think about Emacs.) compared with other text editors, VIM's learning curve is steep. I try my best to introduce only one small topic in each blog so that it is easy for everyone to digest and learn. (This series of blogs are preparing to write 81 articles, which means learning vim can be successful only after 81. I don't know if I can keep writing .) Vi is a widely used full-screen text editor in the Unix world. VIM is short for its IMproved version Vi IMproved, and is tied with Emacs to become the favorite editor for Unix-like users. Almost any Unix machine provides this software. Vim is widely used by programmers because it provides convenient programming functions such as code completion, compilation, and error jump.
A brief history of www.2cto.com VIM vi was written by Bill Joy, who was still in Berkeley. Ken Thompson took his incomplete Pascal system when he went to Berkeley, and Bill Joy got a job to fix it during the summer vacation, he is not satisfied with the editor ed used to fix the code. Exactly. they got em code from a guy named George Coulouris, which is better than ed. They modified em, invented en, and eventually changed to ex (even Bill Joy did not know how to change to ex ). Later, he spent a few months writing vi. When Bram Moolenaar purchased his Amiga computer at the end of 1980s, there was no frequently used editor vi on Amiga. Bram started to copy Stevie from an open-source vi and developed Vim 1.0. The initial goal was to completely copy the vi function. at that time, Vim was short for Vi IMitation (simulation. 1992 version 1.22 of Vim was transplanted to UNIX and MS-DOS. From that time on, the full name of Vim was changed to Vi IMproved (IMproved. Afterwards, Vim has added countless new features, including multi-window editing mode (split windows) and highlight (syntax highlighting) features, code folding, plug-ins, multi-language support, spell check, context-related completion, tab editing, and other new features. Lesson 1 the most basic operation is to run gvim: gvim in command line mode to open a file: gvim file.txt if file.txt does not exist, a new empty file is created. Figure 1 create an empty file file.txt Figure 1 shows a tilde (~) before each line (~), This indicates that this line is not in the file. Because it is an empty file, of course there is no data in a row. The working mode of VIM is different from the general text editor. VIM has three working modes: command mode, insert mode, and VISUAL mode. When vim is started, it is in command mode. press the keyboard I to enter the insert mode. Note that "-- INSERT --" is displayed in the lower-left corner of the window where the file name is originally displayed --". In the insert mode, you can enter text and edit it like a normal editor. When we want to return the command mode, press Key. Move the cursor in command mode. you can use the arrow keys on the keyboard to move the cursor. But the quickest way is the following four keys: Left: h right: l upper: k lower: j because moving the cursor is the most common operation, therefore, assign them the four keys that are most easily pressed in the right hand. Delete a character and a row delete the character of the current cursor: x key delete a row: dd undo and restore undo the most recent operation: u recovery the most recent undo operation: ctrl-R exit and save the current file and exit: ZZ (note that it is two uppercase Z) exit but not save: q! (Colon q, followed by an exclamation point, with three characters) if you only read the file and haven't made any changes, you can save the last exclamation point of the above Command (!) Other basic editing commands insert characters at the end of the current row (entering the insert mode and moving the cursor to the end of the current row): a Key (append) insert an empty line in the next line of the cursor and move the cursor to the next line: o key (open) for help: help subject. for example, you want to see the help of the x command :: help x look at the help of CTRL-A fame: help CTRL-A sometimes, the same shortcut keys in different modes of Time Table different commands, vim by default think that the query is the command in command mode. You can add a prefix to differentiate different modes. I _ indicates the insert mode. V _ indicates the VISUAL mode. : Indicates the ex Mode. For example, the following example: help I _CTRL-H: help: quit repeat a command multiple times you can add a number before the command, for example, I want to insert 10 a at the current position. 10ia Last To return the command mode. If the executed command does not allow vim to enter other modes from the command mode, do not add the final . For example, move the cursor three characters to the left: 3 h OK. you can perform the most basic operations by knowing the above. Practice these skills before starting the second lesson.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.