Table of Contents
1.1 Moving the cursor" >1.1 Moving the cursor
1.3 Delete text editing" >1.3 Delete text editing
1.4 Insertion of text editing" >1.4 Insertion of text editing
1.5 Text Editing Add" >1.5 Text Editing Add
after the cursor position. 2.1 Delete command " > after the cursor position. 2.1 Delete command
2.2 About commands and objects" >2.2 About commands and objects
2.6 Undo commands" >2.6 Undo commands
3.1 Insert class command" >3.1 Insert class command
4.4 Replacement command" >4.4 Replacement command
3.3 Change command (c command, meaning "change")" >3.3 Change command (c command, meaning "change")
3.4 Use c to change more" >3.4 Use c to change more
4.1 Positioning and file status" >4.1 Positioning and file status
4.2 Search command" >4.2 Search command
4.3 Search for matching brackets" >4.3 Search for matching brackets
5.1 How to execute external commands in VIM" >5.1 How to execute external commands in VIM
5.3 A selective save command" >5.3 A selective save command
5.4 Extract and merge files" >5.4 Extract and merge files
6.1 Open the class command" >6.1 Open the class command
6.2 Another version of the substitution command" >6.2 Another version of the substitution command
6.3 Copy and paste text" >6.3 Copy and paste text
Home Operation and Maintenance Linux Operation and Maintenance Summarize some common commands of VIM

Summarize some common commands of VIM

Jun 27, 2017 am 11:20 AM
getting Started Order Commonly used fast

There are many detailed commands in VIM. We have selected some commonly used entry-level commands, which are enough for daily code editing work. If you need to use other commands in the future, it is not too late to check again.

vim generally has three editing modes, namely insert mode, normal mode, and last line mode.

The following are mainly operations in normal mode. Operations in other modes will indicate the relevant modes

1.1 Moving the cursor

h------>Move left each time you press

j------>Down each time you press Move

k------>Move up each time

##l------>Every time Press to move right

1.2 Entering and exiting vim

Press < ;Esc> key to enter normal mode

Then enter the following methods to exit

:q           #不保存并退出vim:q!          #强制退出:wq           #保存文件并退出:x            #相当于:wq
Copy after login

1.3 Delete text editing

In normal mode (Normal mode), you can press the x key to Delete the character at the cursor position.

1.4 Insertion of text editing

Enter insert mode in normal mode, you can There are several methods:

You can press the i key to insert text at the cursor.

Press the a key to insert text behind the cursor.

Press the capital A key to insert text after the last character on the line where the cursor is.

1.5 Text Editing Add

Press the A key and click on the line where the cursor is. Add

to the end of the text. Press the a key and add

after the cursor position. 2.1 Delete command

Enter dw to delete from the cursor to the end of a word.

2.2 About commands and objects

Many commands that change text are composed of an operation The symbol is composed of an action.

The format of the delete command using the delete operator d is as follows:

 dmotion

Among them:

## d   -Delete operator

 motion                                    die through in >> motion     - Delete operator

##A short action list:

w - From the current cursor position to the beginning of the next word, excluding its first characters.

 e - From the current cursor position to the end of the word, including the last character.

 $ - From the current cursor position to the end of the current line.

2.3 Use counting to formulate actions

Enter the number n before the action, it will It repeats n times.

Enter 2w to move the cursor back 2 words.

Enter 3e to move the cursor backward to the end of the 3rd word.

Enter 0 (number zero) to move the cursor to the beginning of the line.

2.4 Use counting to delete more

Enter the number n when using the operator , which can be repeated n times.

For example: operation number (number) motion

d2w You can delete 2 words.

2.5 Operate the entire line

Enter dd to delete a current line and save it to the register, which functions like a "cut" operation and can be used in conjunction with the p operation.

######

2.6 Undo commands

Enter u to undo the last executed command, and enter U to undo modifications to the entire line.

Use Ctrl + r to undo a previous undo command.

3.1 Insert class command

Enter p to "cut" the last time The content is placed after the cursor.

3.2 Replacement command

Move the cursor to the character position to be modified and enter r and a character to replace the character at the cursor position.

3.3 Change command (c command, meaning "change")

To change text until the end of a word, enter ce.

3.4 Use c to change more

 c [number] motion

The action parameter motion is the same, it can be w, e, $d.

4.1 Positioning and file status

Enter Ctrl + g to display the currently edited file The line position of the current cursor and file status information.

Enter capital G to jump directly to the last line of the file.

Enter nG to jump to the line with line number n.

Enter gg to jump to the first line of the file.

4.2 Search command

Enter / plus a string, you can Find this string in the current file. To find the next string, press the n key. To search in reverse, enter a capital N.

If you want to search in reverse, enter ? replace / .

4.3 Search for matching brackets

Position the cursor at the bracket to be matched , enter % to find another bracket that matches it), ], }.

4.4 Replacement command

Enter: s/old/new, you can replace it once The string at old in this line is the string at new.

Enter :s/old/new/g to replace all the strings at old in the line with the strings at new.

Input:#,#s/old/new/g, where #,# represent the line numbers of the starting line and the ending line of the replacement operation.

Enter :%s/old/new/g to replace every matching string in the entire file.

Enter :%s/old/new/gc, each matching string in the entire file will be found, and each matching string will be prompted whether to replace it.

5.1 How to execute external commands in VIM

Enter:! Then enter an external command immediately Execute this external command.

For example, :!ls + Enter, this command lists the contents of your current directory.

5.2 More information about saving files

To save changes to a file, enter :w filename.

5.3 A selective save command

Select by pressing the v key To save part of the file, then enter:w file name to save the selected content to the target file.

5.4 Extract and merge files

To insert another file into the current file For the content, please enter:r file name.

6.1 Open the class command

Enter o, a new file will be opened under the cursor row and enter insert mode.

Enter a capital O to open a new line above the cursor and enter insert mode.

6.2 Another version of the substitution command

Enter uppercase R, you can Replace multiple characters in a row.

6.3 Copy and paste text

Use operator y to copy text and p to paste text.

Enter yy to copy the line where the cursor is.

can be used with the action parameter motion:

Enter yw to copy a word.

The above is the detailed content of Summarize some common commands of VIM. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

A Diffusion Model Tutorial Worth Your Time, from Purdue University A Diffusion Model Tutorial Worth Your Time, from Purdue University Apr 07, 2024 am 09:01 AM

Diffusion can not only imitate better, but also "create". The diffusion model (DiffusionModel) is an image generation model. Compared with the well-known algorithms such as GAN and VAE in the field of AI, the diffusion model takes a different approach. Its main idea is a process of first adding noise to the image and then gradually denoising it. How to denoise and restore the original image is the core part of the algorithm. The final algorithm is able to generate an image from a random noisy image. In recent years, the phenomenal growth of generative AI has enabled many exciting applications in text-to-image generation, video generation, and more. The basic principle behind these generative tools is the concept of diffusion, a special sampling mechanism that overcomes the limitations of previous methods.

How to run SUDO commands in Windows 11/10 How to run SUDO commands in Windows 11/10 Mar 09, 2024 am 09:50 AM

The sudo command allows users to run commands in elevated privilege mode without switching to superuser mode. This article will introduce how to simulate functions similar to sudo commands in Windows systems. What is the Shudao Command? Sudo (short for "superuser do") is a command-line tool that allows users of Unix-based operating systems such as Linux and MacOS to execute commands with elevated privileges typically held by administrators. Running SUDO commands in Windows 11/10 However, with the launch of the latest Windows 11 Insider preview version, Windows users can now experience this feature. This new feature enables users to

Generate PPT with one click! Kimi: Let the 'PPT migrant workers' become popular first Generate PPT with one click! Kimi: Let the 'PPT migrant workers' become popular first Aug 01, 2024 pm 03:28 PM

Kimi: In just one sentence, in just ten seconds, a PPT will be ready. PPT is so annoying! To hold a meeting, you need to have a PPT; to write a weekly report, you need to have a PPT; to make an investment, you need to show a PPT; even when you accuse someone of cheating, you have to send a PPT. College is more like studying a PPT major. You watch PPT in class and do PPT after class. Perhaps, when Dennis Austin invented PPT 37 years ago, he did not expect that one day PPT would become so widespread. Talking about our hard experience of making PPT brings tears to our eyes. "It took three months to make a PPT of more than 20 pages, and I revised it dozens of times. I felt like vomiting when I saw the PPT." "At my peak, I did five PPTs a day, and even my breathing was PPT." If you have an impromptu meeting, you should do it

All CVPR 2024 awards announced! Nearly 10,000 people attended the conference offline, and a Chinese researcher from Google won the best paper award All CVPR 2024 awards announced! Nearly 10,000 people attended the conference offline, and a Chinese researcher from Google won the best paper award Jun 20, 2024 pm 05:43 PM

In the early morning of June 20th, Beijing time, CVPR2024, the top international computer vision conference held in Seattle, officially announced the best paper and other awards. This year, a total of 10 papers won awards, including 2 best papers and 2 best student papers. In addition, there were 2 best paper nominations and 4 best student paper nominations. The top conference in the field of computer vision (CV) is CVPR, which attracts a large number of research institutions and universities every year. According to statistics, a total of 11,532 papers were submitted this year, and 2,719 were accepted, with an acceptance rate of 23.6%. According to Georgia Institute of Technology’s statistical analysis of CVPR2024 data, from the perspective of research topics, the largest number of papers is image and video synthesis and generation (Imageandvideosyn

A must-read for technical beginners: Analysis of the difficulty levels of C language and Python A must-read for technical beginners: Analysis of the difficulty levels of C language and Python Mar 22, 2024 am 10:21 AM

Title: A must-read for technical beginners: Difficulty analysis of C language and Python, requiring specific code examples In today's digital age, programming technology has become an increasingly important ability. Whether you want to work in fields such as software development, data analysis, artificial intelligence, or just learn programming out of interest, choosing a suitable programming language is the first step. Among many programming languages, C language and Python are two widely used programming languages, each with its own characteristics. This article will analyze the difficulty levels of C language and Python

What is the correct way to restart a service in Linux? What is the correct way to restart a service in Linux? Mar 15, 2024 am 09:09 AM

What is the correct way to restart a service in Linux? When using a Linux system, we often encounter situations where we need to restart a certain service, but sometimes we may encounter some problems when restarting the service, such as the service not actually stopping or starting. Therefore, it is very important to master the correct way to restart services. In Linux, you can usually use the systemctl command to manage system services. The systemctl command is part of the systemd system manager

From bare metal to a large model with 70 billion parameters, here is a tutorial and ready-to-use scripts From bare metal to a large model with 70 billion parameters, here is a tutorial and ready-to-use scripts Jul 24, 2024 pm 08:13 PM

We know that LLM is trained on large-scale computer clusters using massive data. This site has introduced many methods and technologies used to assist and improve the LLM training process. Today, what we want to share is an article that goes deep into the underlying technology and introduces how to turn a bunch of "bare metals" without even an operating system into a computer cluster for training LLM. This article comes from Imbue, an AI startup that strives to achieve general intelligence by understanding how machines think. Of course, turning a bunch of "bare metal" without an operating system into a computer cluster for training LLM is not an easy process, full of exploration and trial and error, but Imbue finally successfully trained an LLM with 70 billion parameters. and in the process accumulate

How to use LSOF to monitor ports in real time How to use LSOF to monitor ports in real time Mar 20, 2024 pm 02:07 PM

LSOF (ListOpenFiles) is a command line tool mainly used to monitor system resources similar to Linux/Unix operating systems. Through the LSOF command, users can get detailed information about the active files in the system and the processes that are accessing these files. LSOF can help users identify the processes currently occupying file resources, thereby better managing system resources and troubleshooting possible problems. LSOF is powerful and flexible, and can help system administrators quickly locate file-related problems, such as file leaks, unclosed file descriptors, etc. Via LSOF Command The LSOF command line tool allows system administrators and developers to: Determine which processes are currently using a specific file or port, in the event of a port conflict

See all articles