The difference between VIM commands and Cat commands in Linux __linux

Source: Internet
Author: User

First, vim command:
1. Label command
: Tabe fn Edit the file fn in a new tab page
GT Switch to next tab page
GT Switch to previous tab page
: TABR Switch to First label page
: tabl switch to the Last tab page
: TABM [n] Moves the current tab to the Nth tab
Yes, as you might imagine, a label page with Eclipse, UE, and so on, is a meaning.


2. Window command
ctrl+w s horizontal Split window
Ctrl+w W Toggle Window
Ctrl+w Q exits the current window (this command does not affect other windows because there are multiple files at the same time)
Ctrl+w v Vertical Split window

3. Exit Editor

: W writes the buffer to the file, which saves the modification
: Wq Save changes and exit
: x Save changes and exit
: Q Exits, if the buffer has been modified, you will be prompted
: q! Force exit, Discard changes


4. Find Replace
/pattern     search string pattern
?pattern     Search forward string pattern
n     the next match (if it is/search, the next one is down,? The search is the next up)
n     Previous match (IBID.)
:%s/old/new/g     searches the entire file and replaces all old with new
:%s/old/new/gc      Search the entire file, replace all old with new, and each time you want to confirm whether to replace the


5. Copy and paste
DD deletes the cursor in the row
DW Delete one word (word)
X Delete Current character
X Delete previous character
D Delete to end of line
YY copy a row, which can be followed by a number, identifying multiple rows, such as 6yy, to copy 6 rows starting from the current line
YW copy a word
y$ Copy to end of line
P Pastes the contents of the pasteboard below the current line
P Pastes the contents of the pasteboard onto the top of the current line
]p has indented paste, Vim automatically adjusts the indentation of the Code
"A" put the content into/into a register, you can support the multi-paste Board
Attached: For example, a commonly used register is the system register, the name is +, so paste from the system paste into the vim in the command for "+p, note here the + does not represent the operator, 21 registers."


6. Move cursor
Moving the cursor in VIM is a big difference from other editors, but once you learn it, you can move through the text quickly.

H,j,k,l, down, left, right.
Ctrl-f on a page
Ctrl-b down a page
% jumps to the parentheses that match the current bracket, such as currently in {, then jumps to the place where it matches
W jumps to the next word, divided by punctuation or word
W jumps to the next word first, and the long jump, as end-of-line is considered a word
e jumps to the end of the next word
E jump to the end of the next word, long jump
B Jump to the previous word
B jump to the previous word, long jump
0 jump to the beginning of the line, whether or not indented, is to jump to the No. 0 character
^ The first character to jump to the beginning of a line
$ skip to end of line
GG jumps to the first line of the file
GD jumps to the declaration of the variable where the current cursor is located
N G jump to Nth line, such as 0G, is equivalent to gg,100g is the 100th line
FX finds x characters in current line and jumps to
; Repeat the previous F command without having to repeat the input FX
TX is similar to FX, but only jumps to the previous character of X
FX is in the opposite direction to FX.
), (jump to top/Next statement
* Find the word at the cursor and look down
# Find the word at the cursor, look up
`. Jump to last edit location


7. Move on the screen
H move the cursor to the topmost line on the current screen
M moves the cursor to the middle line on the current screen
L move the cursor to the bottom line on the current screen


8. Bookmark
Ma saves the current position as label a
' A jump to label a


9. Editors
R replaces a character
J joins the next and current lines as one line
CC Deletes the current line and enters edit mode
CW Deletes the current word and enters edit mode
C $ erases content from current position to end of line and enters edit mode
s deletes the current character and enters edit mode
S deletes the cursor line and enters edit mode
XP swaps the current character and the next character
U undo
Ctrl+r Redo.
. Repeat previous Edit command
~ Toggle case, current character
G~IW Toggles the case of the current word
GUIW the current word into uppercase
GUIW the current word into lowercase
>> move the current line one unit to the right
<< move the current line one unit to the left (a tab character)
= = Auto Indent when forward

10. Insert Mode
I enter the insertion mode from the current cursor
I Enter insert mode and place the cursor at the beginning of the line
A append mode, placing the cursor after the current cursor
A Append mode with cursor at end of line
o Add a new row below the current line and enter insert mode
O Add a new row above the current line and enter insert mode
ESC Exit Insert Mode


11. Visual mode, tagged text
V into visual mode, single character mode
V into visual mode, row mode
CTRL + V into visual mode, column mode, similar to UE column mode
o Jump cursor to another endpoint of the selected block
U turn the contents of the selected block into uppercase
O jump cursor to another endpoint of the block
AW Select a Word
AB check everything in parentheses, including the parentheses themselves
AB Select all contents of {} brackets
IB Select the contents of parentheses without parentheses
IB select content in {}, excluding {}

12. Act on a marker
Move the > block to the right
< block left shift
Y copy block
D Delete Block
~ Toggle the case of the contents in the Block


13. Other
Vim does not make actual modifications to the file until it is saved, but is loaded into the buffer, and edits to the file are actually edited to the buffer, until: W will be deposited into the physical file.

: E file loads file into a new buffer
: Bn jumps to the next buffer
: BD Delete buffer (close file)
: SP fn Splits the window and loads FN into a new window


14. Using Macros

: QX starts recording macros and stores the results in register X
Q Exit Record mode
@x play the Macro command recorded in the X register
To explain a little bit, when you enter in normal mode: QX, all your edits to the text will be recorded, then enter Q again to exit the recording mode.
Type, and then enter @x to repeat the command just recorded, this command can be followed by numbers, indicating how many times to repeat, such as @x20, you can repeat 20 times. This is useful in batch processing of text.
Edit multiple files at the same time
In the vim many plug-ins, has a call Minibuffer plug-in, is the following said the tab page function, may support simultaneously edits several files.


Second, Cat command detailed

Cat has three main features:
1. Displays the entire file at once. $ cat filename

2. Create a file from the keyboard. $ cat > filename  
   can only create new files and cannot edit existing files.

3. Merge several files into one file: $cat  file1 file2 > File parameter:
-N or--number number of rows for all outputs started by 1
-B or--number- NonBlank and-n are similar except for blank rows that are not numbered
-s or--squeeze-blank when a blank row with two consecutive rows is encountered, a blank row is substituted for a row
-V or--show-nonprinting
Example:
Insert the Textfile1 file with the line number and enter textfile2 the file
cat-n textfile1 > Textfile2
Adds the Textfile1 and Textfile2 file to the line number (blank line does not Plus) then attach the content to the Textfile3.
Cat-b textfile1 textfile2 >> textfile3   throw Test . txt file into the Trash, null value test.txt
Cat/dev/nul L >/etc/test.txt  

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.