These are the most commonly used commands of VIM! Remember the "Mr.robot" that will improve efficiency
----------------------------------------------------
The common commands that VIM requires:
D G Delete all
I currently edit
o New Line Edit
GG beginning
G Line End
Ten GG jump to line tenth
10 return to car down 10 lines
U undo
CTRL R Anti-undo
YY copy
P Paste
Wq Save exit
X Save exit
Search
Replace
5,10s/111/222/g
%s/xiang/ling/g
Note All lines::%s/^/#/g
Command-line mode:
: Set Nu (show line number)
: Set Paste (format to it when pasting)
: Set Autoindent (auto indent)
/ETC/VIMRC Global, all users, permanently valid
~/.VIMRC to himself, permanently effective
The following command can be written to the global configuration
Auto indent: Set Autoindent/set cindent
Set Highlighting: Syntax on
Set line number: Set Nu
Automatically add file header information
Automatic alignment when pasting: Set paste Cancel Auto-align set noai
---------------------------------------------------------------Details
Linux: Use text files to keep profiles
Text Editor: ASCII file
Emacs VI
Vi:visual Interface
Full screen text editing, nano
Patterned Editor
Moduler
Vim:vi improved
Mode of VI:
Edit mode: Keyboard operations are usually parsed as edit commands:
Input mode:
Last-line mode: Vim's built-in command-line interface to perform vim built-in commands
Edit mode--Input mode
I: Input at current cursor
I: At the beginning of the line where the cursor is currently located
A: After the current cursor is located
A: Enter at the end of the line at the current cursor
O: Add a blank line below the line where the cursor is located
O: Add a blank line above the line where the cursor is located
Input mode--edit mode
Esc
Edit Mode--last-line mode
:
Last-line mode--edit mode
Esc,esc
The use format of the VI command
Vim [Options]/path/to/file
Exit:
: q! Force exit, do not save and exit
: Wq Save changes and exit
: X, Save and exit
Edit mode: ZZ, save exit
Open it:
Multi-file Jump
: Next Next
: Prev Previous
: First One
: Last One
: Qall to exit all files
: Wqall: Modify and exit multiple files
Separate windows to open multiple files
-O: Horizontal separation
Ctrl+w, left and right arrow
-O: Vertical separation
Ctrl+w, up and down arrows
+#: After opening the file at the beginning of # # #
+: After opening the file on the last line
Cursor Movement:
Single character movement:
H: Left
L: Right
J: Next
K: Up
Can be combined with numbers
Move between words:
W: adjust to the beginning of the next word
B: The current or previous word head
E: The ending of the current or next word
In-line movement:
0: The absolute beginning
^: first non-whitespace character
$: absolute end of line
Move between sentences:
): Last sentence
(: The next sentence
Move between paragraphs:
}: Last Paragraph
{: Next paragraph
Move between rows:
#G: The first few lines
G: Last line
Edit operation:
X: Delete the character at the cursor location
#x: Remove the # characters that are backward at the cursor
R: the character at which the cursor is replaced
D: Delete command
The result cursor jump command uses
%: All
DD: Delete a row
#dd: Delete line after row
Last-line mode: Range delimitation
Start,end: Absolute delimitation can be used, or relative delimitation can be used
.: Indicates when the forward
$: Last line
$-2: Bottom 3rd Line
/PAT1/,/PAT2/: The cursor is at the beginning of the row
C: Change
Act like d.
Y:yank, copy
Act like d.
P:paste paste
The entire row is copied or deleted
P: The next line of the current row
P: The previous line of the current row
A non-full row is copied or deleted
P: Paste at the back of the character where the cursor is located
P: Paste in front of the character where the cursor is located
Undo Edit
U:undo
#u: Last 50 operations
Undo the previous undo operation
Ctrl+r:
Repeat the previous command:
.
Flip Screen:
CTRL+F: Flip a screen to the end of the file
CTRL+B: Flip a screen to the file header
Ctrl+d: Turn half screen at the end of the file
Ctrl+u: Turn half screen to file header
Enter: Next line
K: Previous Line
Find:
/keyword
? Keyword
N:
N:
Support for regular expressions
: Set Nohlsearch off highlighting, valid for current shell
The visual mode of VIM
Edit mode:
V: Select the area you have traversed by the cursor
V: Select rectangular block
Vim Visualization mode:
V: Selection of the area traversed by the cursor
V: Select rectangular block
Open multiple files, sub-windows:
Vim-o
Vim-o
Ctrl+w, up and down arrows
Split the current window:
Ctrl+w, S
Ctrl+w, V
Definition of window Properties:
: Set Nu
: Set Nonu
: Set AI Auto Indent
: Set Noai
: Set IC
: Set Noic
Display the corresponding parentheses
: Set SM (show match)
: Set NOSM
Syntax highlighting:
: Syntax on
: Syntax off
Search Highlights:
: Set Hlsearch
: Set Nohlsearch
Vim configuration file:
Global:/ETC/VIMRC
Personal: ~/.VIMRC
Find Replacements:
: Address delimitation s/Find mode/Replace with content/gi
G: Global Substitution
I: Case insensitive
: Address delimitation [email protected] Find mode @ Replace with content @gi
&: Used to refer to all previous matches in the content part of the replacement
Practice:
1. Copy the/etc/grup.conf to/tmp directory and delete the white space character from the beginning of the/tmp/grub.conf file
:%s\^[[:space:]]\{1,\}\\g
2. Copy the/etc/rc.d/rc.sysinit to/tmp directory. Line that starts with at least one white-space character in the/tmp/rc.sysinit file, with the # number at the beginning
:%[email protected]^[[:space:]]\{1,\}.*@#&@g
3. Delete # and whitespace at the beginning of the line beginning with # in the/tmp/rc.sysinit file and followed by at least one white-space character
1,%[email Protected]^#[[:space:]]\{1,\}@@g
4. For/tmp/grub. The first three lines in the Conf file are added with the # number
1,[email Protected]^@#@g
5. Change the enable=0 line in the/etc/yum.repos.d/centos-media.repo to 1 for the last 0;
%@\ (enabled=\) [0-9]@\[email protected]
Bash Knowledge Points: File testing
[]
[[]]
Test
Monocular test:
-e file: Test files exist
-A file: Test files exist
-F file: Test for normal files
-D directory: test for directory files
-B somefile: Test whether the file exists and is a block device file
-C Somefile: Test whether a file exists and is a character device file
-h|-l somefile: Test whether the file exists and is a symbolic link file
-P Somefile: Test whether the file exists and is a pipe file:
-S Somefile: Test whether the file exists and is a socket file:
-R somefile: Test whether its valid users have read access to this file
-W somefile: Test Whether its valid users have write access to this file
-X Somefile: Tests whether its valid users have Execute permissions on this file
-S Somefile: Test file exists and is not empty
Binocular test:
File1-nt file2: Test if file1 is newer than file2
File1-ot file2: Test if file1 is older than file2
Pour other files into the script using the source command
[-R Profile] && cource configuration file
Bash's knowledge point: Position parameter rotation
Shift
#!/bin/bash
Sum=0
For i in ' seq 1 $# ';d o
Let sum+=$1
Shift
Done
Echo $sum
~
This article is from the "Mr.robot" blog, make sure to keep this source http://80602872.blog.51cto.com/12350020/1893914
9.vim Common Command "Mr.robot"