In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
vi: Visual Interface
vim: VI iMproved
Full screen editor,
Vim mode:
Edit Mode (Command Mode)
input mode
last row mode
Mode conversion:
Edit--> Input:
i: Turn to input mode before the character where the current cursor is located;
a: After the character where the current cursor is located, switch to input mode;
o: Create a new line below the current cursor line and switch to input mode;
I: At the beginning of the line where the current cursor is located, switch to input mode
A: At the end of the line where the current cursor is located, switch to input mode
O: Create a new line above the current cursor line and switch to input mode;
Input--> Edit:
ESC
Edit--> Last line:
:
Last line--> Edit:
ESC,ESC
1. Open the file
# vim /path/to/somefile
vim+# : Open the file and navigate to line #
vim+: Open the file and navigate to the last line
vim+/PATTERN : Open the file and navigate to the beginning of the line first matched by PATTERN
Default is in edit mode
II. Close the file
1. Last line mode closes the file
:q Exit
:wq Save and exit
:q! Do not save and exit
:w Save
:w! forced preservation
:wq --> :x
2. Exit in edit mode
ZZ: Save and Exit
Move the cursor (edit mode)
1. Move character by character:
h: Left
L: Right
J: Down.
K: Up
#h: Move #characters;
2. Move in words
w: Move to the beginning of the next word
e: Jump to the ending of the current or next word
b: Jump to the beginning of the current or previous word
#w:
3. Intra-line jump:
0: absolute line header
^: First non-white space character at the beginning of a line
$: Absolute End of Line
4. Interline jump
#G: Jump to line #;
G: Last line
In the last row mode, you can directly give the row number.
IV. Flip screen
Ctrl+f: Scroll down one screen
Ctrl+b: Scroll up one screen
Ctrl+d: Scroll down half screen
Ctrl+u: Scroll up half screen
5. Delete a single character
x: Delete a single character where the cursor is located
#x: Delete #characters at cursor position and backward
VI. Delete Command: d
d command is used in combination with jump command;
#dw, #de, #db
dd: Delete the row where the current cursor is located
#dd: delete the #line including the line where the current cursor is located;
In last row mode:
StartADD,EndADDd
.: Represents the current row
$: Last line
+#: downward #line
VII. Paste command p
p: Paste to the bottom of the line where the cursor is located if the entire line is deleted or copied; paste to the back of the character where the cursor is located if the entire line is copied or deleted;
P: Paste above the line where the cursor is located if the deleted or copied content is the whole line; paste before the character where the cursor is located if the copied or deleted content is not the whole line;
VIII. Copy command y
Same as d command
IX. Modification: delete the content first, and then convert to input mode
c: Same as d command
X. Substitution: r
R: Replacement mode
XI. Undo editing operation u
u: Undo the previous edit
The u command undoes the previous n edits
#u: Undo the last #edits directly
Undo the last undo action: Ctrl+r
XIV. Search
/PATTERN
? PATTERN
n
N
XV. Find and replace
Using the s command in last line mode
ADDR1,ADDR2s@PATTERN@string@gi
1,$
%: indicates full text
Exercise: Replace ftp://instructor.example.com/pub with http://172.16.0.1/yum in the/etc/yum.repos.d/server.repo file
%s/ftp:\/\/instructor\.example\.com\/pub/http:\/\/172.16.0.1\/yum/g
%s@ftp://instructor\.example\.com/pub@http://172.16.0.1/yum@g
The document reads as follows:
# repos on instructor for cla***oom use
# Main rhel5 server
[base]
name=Instructor Server Repository
baseurl=ftp://172.16.0.1/pub/Server
gpgcheck=0
# This one is needed for xen packages
[VT]
name=Instructor VT Repository
baseurl=ftp://172.16.0.1/pub/VT
gpgcheck=0
# This one is needed for clusteringpackages
[Cluster]
name=Instructor Cluster Repository
baseurl=ftp://172.16.0.1/pub/Cluster
gpgcheck=0
# This one is needed for cluster storage(GFS, iSCSI target, etc...) packages
[ClusterStorage]
name=Instructor ClusterStorage Repository
baseurl=ftp://172.16.0.1/pub/ClusterStorage
gpgcheck=0
Edit multiple files using vim
vim FILE1 FILE2 FILE3
:next Switch to the next file
:prev Switch to previous file
:last Switch to the last file
:first Switch to the first file
exit
:qa all exit
Seventeen, split screen display a file
Ctrl+w, s: Split window horizontally
Ctrl+w, v: Split window vertically
Switch the cursor between windows:
Ctrl+w, ARROW
:qa Close all windows
XVIII. Edit multiple files by window
vim -o : Split display horizontally
vim -O : Vertical split display
Save part of the contents of the current file as another file
Use w command in last line mode
:w
:ADDR1,ADDR2w /path/to/somewhere
Fill the current file with the contents of another file
:r /path/to/somefile
21 Interacting with the shell
:! COMMAND
XXII. Advanced Topics
1. Display or cancel the row number
:set number
:set nu
:set nonu
2, display ignore or case-sensitive characters
:set ignorecase
:set ic
:set noic
3. Set automatic retraction
:set autoindent
:set ai
:set noai
4. Highlight or cancel the found text
:set hlsearch
:set nohlsearch
5. Grammar highlighting
:syntax on
:syntax off
XXIII. Configuration Files
/etc/vimrc
/etc/virc
~/.vimrc
vim:
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.