How does the `yy` command differ from `dd` in vi?
时间: 2024-06-16 08:01:08 浏览: 18
The `yy` and `dd` commands in Vi (and its successor Vim) are both used for text manipulation, but they serve different purposes:
1. `yy` (yank or copy): This command selects the text under the cursor and places it into the unnamed register (usually denoted as "0"). It's used to copy the selected text without deleting it from the current position. You can then paste the copied text elsewhere using the `p` command.
2. `dd` (delete): This command deletes the text that is currently selected or moves it to the delete buffer. If you use `dd` without any arguments, it will delete the line containing the cursor. However, if you specify a count (e.g., `3dd`), it will delete multiple lines.
In summary, `yy` copies the text while preserving it, whereas `dd` removes it from the current location. Understanding these basic commands is crucial for efficient text editing with Vi or Vim.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)