blog/vi的基础使用.md

35 lines
1.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: vi的基础使用
tags: linux
categories: linux
date: 2022-03-25 10:37:09
---
# vi的三种模式
+ 命令模式
+ 末行模式
+ 编辑模式
> 命令模式 ==》末行模式 快捷键:冒号
>命令模式 ==》 编辑模式 快捷键: a,i,o ,a代表在光标前输入i代表在光标后输入o代表换行输入
>编辑模式 ==》 命令模式 快捷键esc
# 从vi中退出
+ 进入命令模式
+ 输入**wq** 保存并退出
+ 输入**q** 不保存退出
+ 输入q!强制退出
# 快捷键
+ 移动到末尾,命令模式输入
```:G```
+ 移动到第一行,行尾模式输入```:1```
+ 显示行数,行尾模式输入```:set nu```
+ 取消行数行尾u模式输入```:set nonu```
+ 查询,输入```/```
+ 删除 在命令模式下输入```dd```,删除一整行,在行尾模式输入```:.,%d```,删除所有
+ 复制,在行尾模式输入```:yy```,复制一整行,命令模式下```p```粘贴
+ 命令模式```u```撤销上一步操作
+ 行尾模式下 ```s /old/new/g```进行替换