在vim中忽略冠词(“A”和“The”)进行排序

11

我有一个看起来像下面这样的vim文件:

ABBA
Duran Duran
The Beatles
The Rolling Stones
Styx

使用vim的排序命令会产生以下输出:

ABBA
Duran Duran
Styx
The Beatles
The Rolling Stones
我想要做的是在排序时忽略像“a”和“the”这样的文章。所以期望的输出应该是这样的。
ABBA
The Beatles
Duran Duran
The Rolling Stones
Styx

这可能会有所帮助:https://dev59.com/0HM_5IYBdhLWcg3wcSx_ - Ketan Maheshwari
1个回答

14

看一下:help :sort

当指定了/{pattern}/并且没有[r]标志时,匹配{pattern}的文本将被跳过,这样你就可以按照匹配项之后的内容排序。除了斜杠外,任何非字母都可以使用。

:sort /^\(A \|The \)*/

这让它有点:

(ABBA)
The (Beatles)
(Duran Duran)
The (Rolling Stones)
(Styx)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接