vim编辑器的使用

vim编辑器
作用:用于修改文件内容、编程
一、vim编辑器介绍

模式化
		命令模式
		插入模式
		末行模式
# vim 文件名称
[root@wtl ~]# vim --help
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 15 2020 16:44:08)

usage: vim [arguments] [file ..]       edit specified file(s)
   or: vim [arguments] -               read text from stdin
   or: vim [arguments] -t tag          edit file where tag is defined
   or: vim [arguments] -q [errorfile]  edit file with first error

Arguments:
   --			Only file names after this
   -v			Vi mode (like "vi")
   -e			Ex mode (like "ex")
   -E			Improved Ex mode
   -s			Silent (batch) mode (only for "ex")
   -d			Diff mode (like "vimdiff")
   -y			Easy mode (like "evim", modeless)
   -R			Readonly mode (like "view")
   -Z			Restricted mode (like "rvim")
   -m			Modifications (writing files) not allowed
   -M			Modifications in text not allowed
   -b			Binary mode
   -l			Lisp mode
   -C			Compatible with Vi: 'compatible'
   -N			Not fully Vi compatible: 'nocompatible'
   -V[N][fname]		Be verbose [level N] [log messages to fname]
   -D			Debugging mode
   -n			No swap file, use memory only
   -r			List swap files and exit
   -r (with file name)	Recover crashed session
   -L			Same as -r
   -A			start in Arabic mode
   -H			Start in Hebrew mode
   -F			Start in Farsi mode
   -T <terminal>	Set terminal type to <terminal>
   -u <vimrc>		Use <vimrc> instead of any .vimrc
   --noplugin		Don't load plugin scripts
   -p[N]		Open N tab pages (default: one for each file)
   -o[N]		Open N windows (default: one for each file)
   -O[N]		Like -o but split vertically
   +			Start at end of file
   +<lnum>		Start at line <lnum>
   --cmd <command>	Execute <command> before loading any vimrc file
   -c <command>		Execute <command> after loading the first file
   -S <session>		Source file <session> after loading the first file
   -s <scriptin>	Read Normal mode commands from file <scriptin>
   -w <scriptout>	Append all typed commands to file <scriptout>
   -W <scriptout>	Write all typed commands to file <scriptout>
   -x			Edit encrypted files
   --startuptime <file>	Write startup timing messages to <file>
   -i <viminfo>		Use <viminfo> instead of .viminfo
   -h  or  --help	Print Help (this message) and exit
   --version		Print version information and exit

二、模式间的切换

命令模式  ——————————>	插入模式(INSERT模式)
		a、i、o、O
插入模式  ——————————>	命令模式
			ESC
命令模式  ——————————>	末行模式
			:(英文冒号)

三、末行模式

1、保存退出

:wq

2、强制退出

:q!

3、显示行号

:set nu

4、显示缩进规则(一般用在编写python脚本)

:set list

5、快速替换

:s/旧内容/新内容/    (类似于sed)
:s/csdn/linux
:s/python/linux/g
:10,20 s/arduino/linux
:% s/anaconda/linux/g

四、命令模式
1、快速移动光标

​		h(左)   j(下)    k(上)   l(右) 

​		$   		快速到行尾
	
​		^ 	  		快速到行首 

​		gg			返回第一行 

​		100gg		跳转到指定的行 

​		G			跳转到最后一行 

2、删除

	x	删除单个字符 
​	d$	删除到行尾
​	d^	删除到行首
​	dw	删除光标后一个单词
​	dG	删除到最后一行 
​	dd	删除整行 

3、替换

r 替换单个字符
R 连续替换(进入替换模式)

4、复制、粘贴

yy 		复制 ————————>	p 粘贴
4yy     复制4行——————>	10P 粘贴10次
yw      复制光标后一个单词
y$		复制到行尾
y^		复制到行首

5、搜索

/内容
	n:向下查找
	N:向上查找

6、撤销

u 

案例1:设置vim编辑器的工作特性

[root@wtl ~]# vim /etc/vimrc
			set nu

案例2:打开多个文本文件

[root@wtl ~]# vim -O test.txt test1.txt test2.txt
个人喜欢-O 编辑3个窗格正好,不多不少,使用Ctrl+w+(j/k)控制光标左右移动
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

丶Seman

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值