


























A short note on how to match non-greedily in Nvim/Vim.
Vim’s regex is slightly different from the usal regex we see.
Vim use - to indicate non-greedy match, for example, to match non-greedily for a.*c, we can use the following search:
Note that \v is used to simplify the code.
Otherwise, the command will become ugly and error-prone.
Here is a list of non-greedy syntax (the following assumes that \v is added):
{-n,m}: match n to m previous pattern, non-greedy{-n,}: match at least n of previous pattern, non-greedy{-,m}: match 0 to m of previous pattern, non-greedy{-}: match 0 or more of previous pattern, non-greedy (non-greedy version of *)For more info, read :h non-greedy inside Vim.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。