Use of---VI for Linux articles

Source: Internet
Author: User

First, the foregoing

vi similar to Notepad, so with good notepad on the programming efficiency has a great impact, with a multiplier efficiency.

Second, the specific operation

1. Open File
Vim/path/to/somefile
Vim +#: Open the file and locate it on line #
Vim +: Open the file and navigate to the last line
Vim +/pattern: Open the file and navigate to the beginning of the line that was first matched to the PATTERN

2. Close the file
Last-line mode:
: Q Quit not moving files
: Wq Save and exit moved, no regrets
: q! Do not save and quit the move, I regret it.
: W Save
: w! Forcibly saved
: Wq---: X
ZZ: Save and exit do not require colon, edit mode

3. Full Screen editor
Mode:
edit Mode: Key with edit text function: Default on Enter edit mode
Input mode: The key itself means
Last-line mode: Accept user Command input
Edit--Input:
I: In front of the character of the current cursor, switch to input mode;
A: After the character of the current cursor, switch to input mode;

o: At the bottom of the current cursor line, create a new row and switch to input mode;
O: At the top of the current cursor line, create a new row and switch to input mode;
I: Converted to input mode at the beginning of the line at which the cursor is currently located
A: At the end of the line where the current cursor is located, convert to input mode
Input-to-edit:
Esc
Edit-to-last line:

Last line--edit:
ESC, ESC


4. Edit Mode
Move Cursor
character
h: Left; J: down; K: up; L: Right
Word
W: Move to the beginning of the next word
e: Jumps to the ending of the current or next word
B: Jump to the beginning of the current or previous word
in-line
0: The absolute beginning
^: first non-whitespace character at the beginning of a line
$: Absolute end of line
Between rows
G: End of article
3G: Line 3rd
GG: The beginning of the article
Flip Screen
ctrl:f,b

Delete & Replace a single character
x: Delete cursor position character
3x: Delete cursor start 3 characters
r: Replace cursor position character
Delete command: D
DW,DD
copy paste & Cut
Yw,yy
P
P
Undo & Redo
u undo
ctrl+r Redo undo Operation
. Repeat the previous step

Set: Setting
Set NU number
Set Nonu Nonumber
Set ReadOnly


/: Find
/after
N,n
? Look up
! : Execute command
:!ls-l/

s find and replace
S/str1/str2/gi
/: The first character of the adjacent S command is the boundary character:/,@,#
G: Replace all in one line
I: Ignore case
Range
N: Line number
.: Current Cursor Line
+n: Offset N rows
$: End line, $-3
%: Full text

Use of Linux---VI

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.