Linux Series notes-VIM related records

Source: Internet
Author: User
Tags add numbers


One, the commonly used VIM command


This is a simple record of commonly used commands, followed by commands that you record, but some may not be used.


1 Normal mode:
 2 
 3
 4
 5 gg jump to file header
 6 shift + g jump to the end of the file
 7 lines + gg jump to the specified line eg: 123gg jump to 123 lines
 8 
 9 or support percentage
10
11 50% jumped halfway
12
13 You can add a number in front to refer to a few pages
14 ctrl + f Page forward
15 ctrl + b page backward
16 ctrl + d page forward
17 ctrl + u page backward
18
19
20 u undo
21 ctrl + r recovery
twenty two 
twenty three 
24 ctrl + g show file name
25 1 + ctrl + g show file path and name
26
27
28 dd cut the current line (sometimes also used to delete the current line)
29 yy copy the current line
30 pp paste current line
31 x single character cut
32
33
34 ZZ Exit after saving
35. (dot in English) Repeat the operation of the previous command
36
37
38
39
40 Command line mode:
41
42
43 Find
44
45 / pattern <Enter>: find pattern matching string down
46? Pattern <Enter>: find pattern matching string up
47
48 After using the find command, use the following two keys to quickly find:
49 n: continue searching in the same direction
50 N: Find in the opposite direction
51
52 Enter "/":
53 For example: enter / aaa to find aaa
54
55? Aaa Find aaa
56
57
58 Replace
59
60% s / aaa / bbb / g
61 Replace full text Replace aaa with bbb
62
63 c, e, i, g
64 g replacement without confirmation,
65 c Every replacement requires your confirmation,
66 e does not display an error,
67 i is not case sensitive
68
69:% s / \ t / \ \ \ \ / g
70Replace tab with 4 spaces
71
72
73 Save
74
75 w save
76 wq Save and exit
77 q exit
78 q! Force Quit
79 w! Force save
80
81
82 set nu / nonu show / hide line numbers
83 set invlist show hidden characters
84
85
86 Multi-window operation
87
88 sp anotherfile
89 split file name
90 Display the contents of multiple files on one page at the same time, similar to multiple windows
91
92 ctrl + w + arrow keys Switch between windows
93: set mouse = a switch with mouse click window
94
95: close
96 Close window 




Ii. related orders for records
1 About vim
  2 
  3
  4 vimdiff file1.txt file2.txt
  5 Compare the similarities and differences between two files
  6
  7 vim xxx.php +123 to 123
  8 
  9 
 10
 11 Normal mode:
 12
 13 gg jump to file header
 14 shift + g jump to the end of the file
 15
 16 lines + gg jump to the specified line eg: 123gg jump to 123 line
 17
 18 or support percentage
 19
 20 50% jump to half
 twenty one 
 22 You can add a number in front to refer to a few pages
 23 ctrl + f Turn forward one page
 24 ctrl + b page backward
 25 ctrl + d Flip forward half a page
 26 ctrl + u Flip back half a page
 27
 28 Scroll based on cursor position
 29 zt cursor line to the top of the window
 30 zz ...
 31 zb ..... bottom
 32
 33
 34
 35
 36 0 Move to the beginning of the line (number 0)
 37 ^ move to the beginning of a non-empty string
 38 $ move to end of line
 39
 40
 41 fx move the cursor to the first ‘x’ character on the right, you can add numbers in front, such as: 3fx on the third character
 42 Fx .......... Left ...............
 43 tx right front
 44 Tx left front
 45
 46
 47 w move the cursor to the beginning of the next word
 48 b previous prefix
 49 e next suffix
 50 ge previous suffix
 51
 52
 53 W Move the cursor to the beginning of the next string
 54 B .......... the beginning of the previous string
 55 E Next End
 56 gE Previous End
 57
 58
 59
 60
 61
 62
 63 u undo
 64 ctrl + r recovery
 65
 66
 67 ctrl + g show filename
 68 1 + ctrl + g show file path and name
 69
 70
 71
 72 zc fold
 73 zC Collapse all nested fold points in the range
 74 zo unfold
 75 zO Expand all nested fold points in the range
 76
 77
 78
 79 The correct answer is:
 80 ggVG
 81 Slightly explain the above command
 82 gg move the cursor to the first line, only valid in vim, invalid in vi
 83 V is in Visual mode
 84 G cursor moves to the last line
 85 After selecting the content, you can perform other operations, such as:
 86 d delete selected
 87 y Copy selected content to register 0
 88 "+ y Copy selected content to + register, which is the system's clipboard for other programs
 89
 90
 91
 92
 93
 94 command mode:
 95
 96 1. Full text replacement:
 97
 98% s / aaa / bbb / g
 99
100 Full text replacement Replace aaa with bbb
101
102 c, e, i, g
103 g without replacement confirmation,
104 c Every replacement requires your confirmation,
105 e does not display an error,
106 i is not case sensitive
107
108
109 2. Find
110
111 Enter "/":
112 For example: enter / aaa to find aaa
113
114? Aa Find aaa
115
116
117 / pattern <Enter>: search down for pattern matching string
118? Pattern <Enter>: find pattern matching string up
119
120 After using the find command, use the following two keys to quickly find:
121 n: continue searching in the same direction
122 N: Search in the opposite direction
123
124
125 3.Common set
126
127 set cursorline
128 underline per line
129
130 set nu set nonu
131 show / hide line number
132
133: set invlist
134 Show hidden characters
135
136
137:% s / \ t / \ \ \ \ / g
138 Replace tab with 4 spaces
139
140
141: sp anotherfile.php
142: split filename
143 Display the contents of multiple files on one page at the same time
144
145 ctrl + w + arrow keys Switch between windows
146: set mouse = a switch with mouse click window
147
148: close
149 Close Window
150
151
152
153 ctrl + R Search for commands entered in the command line window
154
155
156
157 After vim opens the file,
158 ctrl + z will put a command in the foreground in the background and pause
159
160 At this point, you can run the jobs command to view all programs running in the background
161 Then fg number can start the corresponding program 




Third, vim command diagram


Finally upload a vim command related diagram, super powerful









Linux Series notes-VIM related records


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.