linux vi命令查找技巧

向下查找:

/pattern
然后按Enter

下上查找:

?pattern
然后按Enter

n键--同方向继续查找下一个:

N键-反方向查找下一个:


设置查找结果高亮显示:

:set hlsearch

设置完后效果是这样的:

图片来源于:https://linux.cn/article-8288-1.html


搜索时不区分大小写:

扫描二维码关注公众号,回复: 685731 查看本文章
:set ignorecase

或简写为:

:set ig

恢复为区分大小写:

:set noignorecase

或简写为:

:set noic

搜索字符串A之后出现的字符串B(二者不一定在同一行),使用;将两个搜索隔开:

/stringA/;/stringB/


其他使用技巧:

打开行号:

:set number

或简写为:

:set nu

关闭行号:

:set nonumber

或简写为:

:set nonu

设置自动缩进:

:set autoindent

或缩写为:

:set ai

关闭自动缩进:

:set noautoindent

或缩写为:

:set noai

设置缩进级别:

:set shiftwidth=4

在一个命令里开启自动缩进并设置缩进级别:

set ai sw=4

参考:

https://www.ibm.com/developerworks/cn/aix/library/au-vitips.html



猜你喜欢

转载自blog.csdn.net/nianbingsihan/article/details/80283850