Dark Horse programmer-vim Editor, dark horse programmer-vim

Source: Internet
Author: User
Tags class operator

Dark Horse programmer-vim Editor, dark horse programmer-vim

I. Basic operations

1. ENTER the vim Editor: vim filename <ENTER> from the command prompt.

2. move the cursor

Left shift: h

Shift right: l

Move up: k

Move down: j

3. Delete the character where the cursor is located: x

4. insert or add text:

I insert text before the cursor

A attaches text behind the cursor

5. Delete the current row and save the row to the clipboard: dd

6. paste the clipboard: p

7. Display related command help: help <command>

Exit the help input: q <ENTER>

8. Exit the Editor:

: Q! Discard modification and exit

: Wq: Save the modification and exit.

After the vim editor is started, vim is in normal mode. You can use the above command operators for basic operations. When I or a is used, the insert mode is enabled. You can enter text. You can use esc to exit the insert mode and return to the normal mode again.

The above basic operations can meet the basic needs of the normal mode. The subsequent expanded command operators also need to be operated in the normal mode.

 

Ii. Basic Format of command Operators

Operator [number] motion

It means:

Operator: indicates what to do

[Number]: The number of times the command is executed.

Motion: indicates the object to be operated.

 

Iii. Delete and revoke class commands

(1) Delete class commands

Delete class command d in the format

D [number] motion

Dw: delete from the cursor to the next word (including spaces)

De: remove from the cursor to the end of the next word (excluding spaces)

D $: delete from the cursor to the end of the current row

(2) revoking commands

U: Undo previous operations

N: undo the changes made in a row.

CTRL-R: Undo undo command to restore previous operations

 

Iv. Placement, replacement, and modification commands

(1) Placement commands

I: insert text before the cursor

A: Add text behind the cursor

A: insert text at the end of the row where the cursor is located

P: place the deleted text content after the cursor. If the last row is deleted, the row is placed in the next row where the current cursor is located.

O: open a new line under the cursor

Shfit-o: open a new line above the cursor

(2) Replacement class

R: Replace the character of the cursor

R: Enter the replacement mode. At this time, you can replace the content after the cursor until the esc enters the normal mode.

: S/old/new: Replace the first string in one line with old as the new string.

: S/old/new/g: replace all strings in one row with the new string, new

: #,# S/old/new/g: replace all strings old with the new string new (# Representing the row number) in the two rows)

: % S/old/new/g: replace all strings in the file. old is the new string.

: % S/old/new/c: Ask the user to confirm each replacement during full-text replacement

(3) change the class operator format

C [norber] motion

Columns such as cw and c $

 

5. Positioning and search commands

(1) Positioning

CTRL-g: displays the position of the current cursor and the file status.

SHIFT-g: Jump the cursor to the last line of the file

[Number] SHIFT-g: Jump to the row number represented by number

Gg: Jump to the beginning of the file

(2) search commands

/String: Search for the string after the current cursor

? String: Search for the string before the current cursor

N: Repeat the previous search in the same direction.

Shift-n: the reverse side repeats the previous search

%: If the cursor is at (), {}, [], enter % to find matching parentheses.

 

6. Saving, extracting and merging text

In vim, you can use an external command in the format ::! Command

:! Ls: used to display the content of the current directory

:! Rm filename: Used to delete a file named filename

: W filename: used to save the edited file named filename in vim.

V motion: w filename: Save the selected row in the filename file.

: R! Ls: insert the contents of the current directory behind the cursor of the current file

 

7. Set the command selection for the class

: Set xxx: it can be a xxx option, for example:

'Ic ': case-insensitive during search

'Is': displays a matching search result.

'Hls': highlight all matching results

You can cancel the pre-set 'no', for example, set noic.

 

If you want to play vim, the above basic content is far from enough, but it is a good start to lay a solid foundation. In the future, we will explore the deeper and more convenient methods of programming, make vim a good tool for success.

 

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.