First, the other text editor has only one mode, which is insert mode. And Vim has revolutionized our worldview-there are many patterns. This is the switch of thinking, it is very difficult and important!!!
Second, Vim provides a pattern-sensitive user interface. This means that the same keys may produce different results in various modes. A lot of quick how to remember? Memory after a period of time not to use and back to vim. This is because there is no clear responsibility and use of the scene, did not build a complete set of vim knowledge system. And we use the model as the carrier to build the VIM knowledge system.
Objective
This paper introduces the common mode functions and mode switching of vim, and reduces the repetition time caused by continuous thinking and correcting what mode of the scene is used .
Brief introduction
There are two main types of patterns: Basic mode and derivative model. There are many patterns in each category. Can be used directly in more detail: H vim-modes
This is mainly about the 4 patterns commonly used in basic patterns. Based on these 4 modes, other patterns will be involved.
Common mode Responsibilities
Responsibilities are mainly considered in the following two aspects
- Exclusive: This responsibility is unique to this model and cannot be replaced
- Good: This is the function of this mode to operate faster than other modes of the same functionality.
Insert Exclusive
- You need to go into insert mode only if there is a requirement to enter new text that does not exist for the current text. If you do not have the previous requirements, do not arbitrarily enter the insert, because switching back and forth is time consuming and laborious.
Good at
- In order to edit the text content, of course, these editors must have a new input, or you should not use the Insert mode. You can now edit text faster with automatic hints and registers, and integrate existing text more quickly while editing new text .
Visual
? I haven't figured it out yet. There is no better scene at the moment. You are welcome to study and discuss together.
Normal unique
- Line-level cursor movement: Left and right, word movement
- Shielded scrolling.
- Record a macro.
Good
A shortcut key directly selects the action of the area directly, and then executes the action directly. That is, a move + an action, preceded by a mentioned ideal state. Contrast the text editing scene that distinguishes Cmd-line.
Cmd-line Exclusive
- Direct text reads and writes from other sources. Reads text from other files, reads text from commands, and so on.
- File operations. New, save, Save as, file switch.
- The editor shape is configured. With set, the shape of the editor is.
- Invokes the shell command. Commands can be used in the editor.
Good
- Text editing that involves a range. directly into the command mode, with a complete command input to solve, this is the first range, and then perform the action, thinking more complete. Compare text editing scenarios that distinguish normal.
Switching mode switching mode switch in transit
This relay is normal mode.
Although there are many kinds of patterns. However, there are some modes that cannot be switched between. Details can be viewed by: H vim-modes
Simple memory: Switch mode before you go back to normal mode, and then enter the mode to switch. Some special mode switches are recorded below
Common switching *-->normal
Press ESC or ctrl+[to return to normal. Many of the online modifications are also mapped. But personal more accustomed to press ESC, just in the switch mode, a little adjustment of thinking, so that the tension of the mind to ease a bit.
Normal-->cmd-line
Press/|?| : |!, that is, switch to Cmd-line.
Normal-->visual
- Shortcut key: V, function: Free selection
- Shortcut keys: Ctrl + V, function: Column selection
- Shortcut key: Shift+v, Function: Row selection
Normall-->insert
This is the most commonly used switching mode. It is important to note that each operation is a separate, complete concept with its corresponding scenario.
- Shortcut key: I, function: Enter the body on the left side of the cursor.
- Shortcut keys: I, Function: inserted at the beginning of the line (excluding whitespace characters, such as spaces).
- Shortcut key: GI, Function: Inserts the position of the cursor into the insertion mode the last time.
- Shortcut keys: GI, function: Inserting at the beginning of the line (note the difference i)
- Shortcut key: A, function: Insert after cursor
- Shortcut key: A, function: Insert at end of line
- Shortcut key: s, function: Delete the word that the cursor is located Fu insert
- Shortcut key: S, function: Delete entire row and then insert
- Shortcut keys: C, Function: More flexible insertion, usually followed by positioning words ($,b,w,0, etc.), cc means to delete the entire line into the insert mode.
- Shortcut key: C, Function: Delete the cursor to the end of the content and then insert
- Shortcut key: O, function: Under the current line new CCB
- Shortcut key: O, Function: On the current line on the new CCB
Special Switch Insert-->insert Normal
This is a special switch from insert to insert Normal, enter Ctrl+o. The " One"normal operation is executed and then continues to return to the insert
Application Scenarios
- Sometimes I scroll through the screen to see more context when the current line is exactly at the top or bottom of the window. The ZZ command allows you to redraw the screen and display the current line in the middle of the window so that you can read the half-screen content above and below the current line. I often type <c-o>zz and trigger this command in insert-Normal mode. When this is done, it goes straight back to insert mode, so I can continue typing without interruption.
Based on the present cognition, this paper summarizes the continuous revision of cognition in the subsequent study. You are welcome to discuss correct.
A tentative study on the growth of rookie Vimer--2.0 chapters and models