Basic operation of Vi/vim editor contents
- 1. Tool Preparation (Download Gvim)
- 2. Basic Introduction to Vi/vim
- 2.1. Installation
- 2.2. Basic use
- 3. Vi/vim Basic Command table
1 Tool Preparation (download Gvim)
nonsense : Since our goal is to learn VI/VIM operations, it is not necessary to stress the use of Vi/vim under the Linux system, which uses the Windows version of Gvim (Gvim is the GUI-enhanced version of Vi/vim).
net disk download : HTTP://PAN.BAIDU.COM/S/1HQFACH2
official website Download : http://www.vim.org/download.php#pc
2 Basic Introduction to Vi/vim2.1 Installation
The Vi/vim installation under Windows is simple. There's no more nagging here.
2.2 Basic Use
3 Ways to enter Gvim under Windows
- Click Gvim74 to enter directly.
- Win+r then enter Gvim and return to enter.
- Win+r enter cmd into the console and enter Gvim in the console.
Tips
- You can also replace Gvim with VIM to enter the console version.
VI/VIM3 Basic mode of operation:
Command-line mode |
Controls the movement of the screen cursor, the deletion of characters, words or lines, moving, copying an area and inserting mode, or to the last line mode. |
Insert mode |
Only in the Insert mode, you can do text input, press the "ESC" key to switch to the command line mode. |
Last-line mode |
To save the file or exit the Vi/vim editor, you can also set the editing environment, for example: List line numbers, find replacement strings, and so on. |
Required Mobile keys:
Upper K left J L right J below is the arrow key under Vi/vim, using: Switch to command-line mode by K (UP), J (bottom), h (left), L (right) to move the cursor.
After entering GIVM, in command-line mode, press "I" to enter insert mode (note that it is lowercase i) at this point you can enter the content you want in your editor. Here is a simple C program, for example, the following steps:
I
#include <stdio.h>int main () { printf ("Welcome to Friends Song blog"); return 0;}
- Switch to command-line mode
Esc
Shift +:
- Saving files to the desktop
W DESKTOP/WELCOM.C
Shift +: Q
After the order is complete, you can almost simply use the Gvim editor. Here, to learn vi/vim the simplest way is to use it, as far as possible, full keyboard operation, do not use the mouse. (When you all work with the keyboard to complete, is not a kind of hacker's sense of foot, a bit of forced, hehe)
Tip: "Desktop" Here is our Desktop directory.
3 vi/vim Basic command Table
The following commands are commonly used by the VI editor for informational purposes only.
Related information: [http://www.vim.org/docs.php]
Vi/vim Help Documentation: [http://vimdoc.sourceforge.net/htmldoc/help.html]
Command |
Description |
Vi |
Enter the VI editor from the console |
VI filename |
Create a file named filename and go to the VI editor |
Command-line mode |
|
I |
Insert from the word match either the cursor |
A |
Specifier insert from the word where the cursor is located |
O |
Insert a blank line from below the line where the cursor is located |
I |
Insert from the beginning of the line where the cursor is located |
A |
Insert from the end of the line where the cursor is located |
O |
Insert a blank line from the top of the line where the cursor is located |
S |
Remove the character of the cursor into insert mode |
S |
Delete cursor line into insert mode |
Esc |
Insert mode switch to command line mode |
K |
Similar to the arrow keys |
J |
Similar to the direction key |
H |
Similar arrow keys Left |
L |
Class is the arrow key right |
Ctrl+u |
Move up half a page |
Ctrl+d |
Move Down half a page |
Ctrl+b |
Move up one page |
Ctrl+f |
Move down one page |
0 |
Cursor moves to the beginning of the line |
Gg |
Move to the first line of text |
G |
Move to the last line of text |
$ |
The behavior of the cursor moving to the same row |
^ |
Cursor moves to the beginning of the line |
W |
Cursor jumps to the beginning of the next word |
E |
Cursor jumps to the end of the next word |
B |
Cursor back to the beginning of the last word |
X |
Delete one character at the cursor location every time you press |
Nx |
"3x" means 3 characters from the beginning of the position where the cursor was deleted. |
X |
Delete the previous character at the cursor location |
Nx |
For example, "3X" means the first 3 characters of the position where the cursor was deleted |
Dd |
Delete the cursor in the row |
Ndd |
For example, "3DD" means to delete the 3-line character at the beginning of the cursor. |
yw |
Copy the character from the cursor to the end of the word to the buffer |
Nyw |
Copy n characters to a buffer |
P |
Writes the contents of the buffer to the cursor location |
R |
Replace the character at which the cursor is located |
R |
Replace the character at which the label is located until ESC is pressed |
U |
Undo command, can be revoked multiple times |
Ctrl+g |
Lists the line number of the line where the cursor is located |
NG |
Represents moving the cursor to the beginning of the nth line of text |
Zz |
Save to exit |
ZQ |
Do not save the disk exit |
Last-line mode |
|
: |
Press ESC first to enter command line mode and press ESC to enter the last line mode |
Set Nu |
Turn on line numbers for each line |
Set Nonu |
Cancel line number of each line |
N |
n represents a number that jumps to n rows |
/keywords |
First press "/", enter the keyword after entering the search character (find), press N to find the next |
? Key words |
Similar to "/keyword" |
! Command |
Run the DOS command under Windows, run the shell command under Linux |
S/a/b |
Replace the first a in the row of the cursor with the B |
s/a/b/g |
Replace a all of the lines of the cursor with B |
W |
Save the modified file |
W filename |
Save and name the filename |
Q |
Exit VI |
Q! |
Forced exit VI that cannot be exited |
Wq |
Save and exit |
Author: Lu Xiaoyu
created:2015-04-23 Thursday 22:08
Website:luxiaoyou.com (about)
Sina Weibo:http://weibo.com/yougelu
Category: Vim
Basic actions for the Vi/vim editor