Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编辑打开的文本文件中的第 N 行vim。我想找到所有出现的模式 P 或模式 Q 当且仅当它们出现在包含范围 [NK, N+K] 的行号中,其中 K 是定义变量的值。这样的事情有可能吗?这将是一个非常需要的脚本的基础......
vim
:-5,+5g/P\|Q
显示包含P 或 Q介于当前行上方 5 行和下方 5 行之间的所有行。
P
Q
看看:help search()你是否想在脚本中这样做。
:help search()
有关:help range范围的更多信息,请参阅。
:help range