Linuxvi move cursor command

Source: Internet
Author: User
Linux universal technology-Linux programming and kernel information. For more information, see the following. Move cursor
Up: k nk: up to n rows 9999k or gg can be moved to the first row G to the last row
Bottom: j nj: Move n rows down
Left: h nh: Move n columns to left
Right: l nl: Move n columns to the right

W: move cursor forward by word nw: move the cursor forward by n words to the first letter of the word
B: opposite to w
E: move the cursor forward by words. ne: move the cursor forward by n words to the last letter of the word.
Ge: opposite to e

$: Move the cursor to the end of the row n
0 (Num): move the cursor to the beginning of the line
^: Move the cursor to the first non-empty character in the line

F: move the cursor to character a of the current row, and nf move the cursor to CHARACTER n of the current row.
F: opposite

%: Move to the matching brackets (), {}, [], <>, and so on.

NG: Move to line n G: to the last line

CTRL + G to get the position of the current cursor in the file

Flip forward: CTRL + F
Move down the half screen: CTRL + G
Flip back: CTRL + B

Disk Storage:
: Q! : Exit without saving the disk
: E! : Discard modifying the file content and reload the file for editing.
: Wq: the disk is logged out.

Dw: to delete a word, move the cursor to the first letter of the word and press dw. If the cursor is at any position of the word, use daw
Dnw: delete n words
Dne: Yes, but it is deleted to the end of the word.
Dnl: delete n letters to the right
Dnh: delete n letters from the left
Dnj: delete n rows down
Dnk: delete n rows up
D $: Delete the letter from the current cursor to the end of the row to be changed
Dd: delete a row
Cnw [word]: Change n words to word
Cc: change the entire line
C $: change to the end of the row

J: Delete the line break, move the cursor to the new line, and press shift + j to delete the line break at the end of the line. The next line is connected.
U: undo the previous operation
Shif + u (U): cancels all operations on the row.

: Set showmode: sets the display mode.

O: Start another row under the current row.
O (shift + o): Start another row above the current row

Nk or nj: move the cursor up or down n rows, n is a number
An! [ESC]: add n exclamation points (!) to the end of the row (!)
Nx: executes n x (delete) operations.

ZZ: Save the current document and exit VIM.

: Help: view the help document. In this example, press CTRL +] to enter the hyper-connection, and press CTRL + O to return.
: Help subject: view the help of a topic. ZZ exits.

: Set number/set nonumber: Show/do not show row number
: Set ruler/set northeasters: Display/do not display the ruler

/Pattern searches for one character mode in the square direction
? Search for a character pattern in the opposite direction
Then press n to continue searching.

Place the cursor over a word and press the X key to search for the word.
Search for the entire word :/\

: Set hlsearch highlight the searched words
: Set nohlsearch disable the modification function

M [a-z]: Mark in the text. The mark number can be 26 letters of a-z. 'A can be used to move to.

R: Replace the current character
Nr character: replaces the current n characters

Search replacement:
Way1:
/[Word]: Find a word
Cw [newword]: replace it with the new word
N: Continue searching
.: Replace

Way2:
: S/string1/string2/g: replace string1 with string2 in a row, and g indicates that the execution needs to be confirmed using c.
: Num1, num2 s/string1/string2/g: replace string1 with string2 between num1 and num2.
: 1, $ s/string1/string2/g: replace string1 with string2 In the full text.


V: Enter visual mode
[ESC] exit
V: shift + v visual mode for entering the row
CTRL + V: in block operation mode, use o and O to change the size of the selected edge.

Paste: p, which is the text deleted with x or d.
Copy:
Ynw: Copy n words
Yy: copy a row
Ynl: Copy n characters
Y $: copy the current cursor to the end of the row
Nyy: Copy n rows
Paste with p

: Split a window
: Split file. c: separates windows from another file. c.
: Nsplit file. c: separates the window for another file. c and specifies the number of rows.
CTRL + W switch in the window
: Close the current window

Insert the same content in all rows, such as include. The operation is as follows:
Move the cursor to the start position, press CTRL + V to enter the VISUAL mode, and select the module.
Press I (shift + I), insert the text to be inserted, and press [ESC.

: Read file. c: insert the file. c content under the current cursor
: 0 read file. c Insert the content of file. c to the beginning of the current file (row 0th)
: Nread file. c Insert the content of file. c to the end of row n of the current file.
: Read! Cmd: insert the output of the external command cmd to the bottom of the current cursor.

: N1, n2 write temp. c: write the n1 in this file to the n2 row into the temp. c file.

CTRL + L refresh the screen
Shift + <move one row left
Shift +> move one row to the right

U: undo
CTRL + R: re-do
J: merge a row
CTRL + p Automatic completion
CTRL + g to view the full path of the current file

Q [a-z] starts the record, but the previous operation is macro, the name can be [a-z], and then ends the recording macro with q.
Use reg to display all macros currently defined, and use @ [a-z] to execute macro [a-z] at the current cursor.
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.