


Several key skills to master the vi editor of Linux system
In Linux systems, the vi editor is a widely used text editor. For system administrators and programmers, it is crucial to master the skills of vi editor. This article will share some commonly used vi editor skills to help readers improve editing efficiency.
Enter vi editor
To enter the vi editor, just type "vi file name" in the Linux terminal. To edit a specific file directly, use "vi filename" from the command line.
Switching between command mode and insert mode
The vi editor is divided into two modes: command mode and insert mode. In command mode, you can execute various commands to manipulate text; in insert mode, you can enter and edit text content. To switch between the two modes, just press the "Esc" key.
Move cursor
In command mode, you can use the following commands to move the cursor:
h:向左移动一个字符 j:向下移动一个字符 k:向上移动一个字符 l:向右移动一个字符 Ctrl + B:向上滚动一页 Ctrl + F:向下滚动一页
Delete text
In command mode, you can use the following command to delete text:
x:删除光标所在字符 dw:删除光标所在单词 d$:删除光标至行尾的所有字符 d^:删除光标至行首的所有字符 dd:删除光标所在行
Copy and paste text
In command mode, you can copy and paste text using the following commands:
p:将剪贴板中的内容粘贴到光标后面 P:将剪贴板中的内容粘贴到光标前面 yy:复制光标所在行 yw:复制光标所在单词 y$:复制光标至行尾的所有字符 y^:复制光标至行首的所有字符
Undo and redo operations
In command mode, you can use the following commands to undo and redo operations:
u:撤销最近一次操作 U:撤销所有操作 Ctrl + R:重做最近一次撤销操作
Display line number
The vi editor can display the line number by setting the line number. In command mode, use the following command to set the display line number:
- Display the line number in the current line: enter ":set number" and press the Enter key
- Display line numbers on all lines: Enter ":set number!" and press Enter
Search and replace text
The vi editor also supports searching and replacing text. In command mode, use the following commands to search and replace text:
搜索文本:输入“/关键词”并按回车键,将光标移动到第一个匹配的字符处。输入“n”可以继续搜索下一个匹配的字符。 替换文本:输入“:%s/旧关键词/新关键词/g”并按回车键,将文件中所有出现的旧关键词替换为新关键词。输入“n”可以继续替换下一个旧关键词。
Set text properties
In command mode, you can use the following command to set text properties:
i:进入插入模式,在光标所在位置插入文本 I:进入插入模式,在行首插入文本 a:进入插入模式,在光标所在位置后面插入文本 A:进入插入模式,在行尾插入文本
vim is the upgraded version of vi
vi is a screen editor provided by all UNIX systems, and some are also called multi-mode editors. It provides a window device through which files can be edited, and vim is an upgraded version of vi. It is not only compatible with vi All instructions, and there are some new features in it. The following are some advantages of vim compared to vi
1. Multi-level undo
在vi里,按 u只能撤消上次命令,而在vim里可以无限制的撤消
2. Ease of use
vi只能运行于unix中,而vim不仅可以运行于unix,windows ,mac等多操作平台
3. Syntax highlighting
vim可以用不同的颜色来加亮你的代码。
4. Visual operation
vim不仅可以在终端运行,也可以运行于x window、 mac os、 windows。
5. Full compatibility with vi
vi和vim都是Linux中的编辑器,不同的是vim比较高级,可以视为vi的升级版本。 vi使用于文本编辑,但是vim更适用于coding。 注:coding是编码的意思,decoding是解码的意思
The above is the detailed content of Several key skills to master the vi editor of Linux system. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



What does WeChat Do Not Disturb mode mean? Nowadays, with the popularity of smartphones and the rapid development of mobile Internet, social media platforms have become an indispensable part of people's daily lives. WeChat is one of the most popular social media platforms in China, and almost everyone has a WeChat account. We can communicate with friends, family, and colleagues in real time through WeChat, share moments in our lives, and understand each other’s current situation. However, in this era, we are also inevitably faced with the problems of information overload and privacy leakage, especially for those who need to focus or

iOS devices have long been able to track your sleep patterns and more using the Health app. But isn’t it annoying when you’re disturbed by notifications while you’re sleeping? These notifications may be irrelevant and therefore disrupt your sleep patterns in the process. While Do Not Disturb mode is a great way to avoid distractions while sleeping, it can cause you to miss important calls and messages you receive during the night. Thankfully, this is where sleep mode comes in. Let’s learn more about it and how to use it on iPhone. What role does sleep mode play on the iPhone? Sleep mode is a dedicated focus mode in iOS that is automatically activated based on your sleep schedule in the "Health" App. It helps you set an alarm and then

There is no better way to write Python code than using an integrated development environment (IDE). Not only can they make your work simpler and more logical, they can also improve programming experience and efficiency. Everyone knows this. The question is, how to choose the best Python development environment among the many options.

C language is a basic and important programming language. For beginners, it is very important to choose appropriate programming software. There are many different C programming software options on the market, but for beginners, it can be a bit confusing to choose which one is right for you. This article will recommend five C language programming software to beginners to help them get started quickly and improve their programming skills. Dev-C++Dev-C++ is a free and open source integrated development environment (IDE), especially suitable for beginners. It is simple and easy to use, integrating editor,

Even answering calls in Do Not Disturb mode can be a very annoying experience. As the name suggests, Do Not Disturb mode turns off all incoming call notifications and alerts from emails, messages, etc. You can follow these solution sets to fix it. Fix 1 – Enable Focus Mode Enable focus mode on your phone. Step 1 – Swipe down from the top to access Control Center. Step 2 – Next, enable “Focus Mode” on your phone. Focus Mode enables Do Not Disturb mode on your phone. It won't cause any incoming call alerts to appear on your phone. Fix 2 – Change Focus Mode Settings If there are some issues in the focus mode settings, you should fix them. Step 1 – Open your iPhone settings window. Step 2 – Next, turn on the Focus mode settings

Many Windows users have encountered the problem of being unable to log in to Windows 11/10 systems due to failed login attempts or multiple system shutdowns. Users are frustrated because there is nothing they can do about it. Users may forget their PIN code to log into the system, or experience lags when using or installing software, and the system may be forced to shut down multiple times. Therefore, we have compiled a list of the best available solutions that will undoubtedly help consumers solve this problem. To learn more, continue reading this article. Note: Before doing this, make sure you have your system's administrator credentials and Microsoft account password to reset your PIN. If not, wait an hour or so and try with the correct PIN

Solution to Linuxvi not displaying the cursor: 1. Log in to the Linux system and enter the terminal; 2. Display the cursor by executing the "echo-e"\033[?25h"" method. The Linux terminal cursor disappears problem. When I was writing a script in vim today, I suddenly found that the cursor disappeared. This was very uncomfortable. I didn’t know where the editing position was. At first I was looking for vim configuration issues, but later I found that the terminal cursor also disappeared. Only then did we know that the terminal's cursor and vim's cursor are related, so we only need to get out the terminal's cursor. Hide the cursor echo-e"\033[?25l"Show the cursor echo-e&quo

Title: Introduction to Go language development tools: List of essential tools In the development process of Go language, using appropriate development tools can improve development efficiency and code quality. This article will introduce several essential tools commonly used in Go language development, and attach specific code examples to allow readers to understand their usage and functions more intuitively. 1.VisualStudioCodeVisualStudioCode is a lightweight and powerful cross-platform development tool with rich plug-ins and functions.
