See :help :sort
.
:[range]sor[t][!] [b][f][i][n][o][r][u][x] [/{pattern}/]
When
/{pattern}/
is specified and there is no[r]
flag the text matched with{pattern}
is skipped, so that you sort on what comes after the match.
- You have a list of URLs to sort by domain name, each on a separate line.
- The protocols are mixed
http
andhttps
, moreover some URLs havewww.
and others do not. You wish to sort only by meaningful domain. - In (Neo)Vim Visual mode, select the list, invoke
sort
, and condition it on a regular expression.
:'<,'>sort /https\?:\/\/\(www\.\)\?/
" or even:
:'<,'>sort /ps\?:\/\/\(www\.\)\?/
Given this:
1. <http://x>
1. <https://bb>
1. <https://www.ba>
1. <http://www.a>
The effect is this:
1. <http://www.a>
1. <https://www.ba>
1. <https://bb>
1. <http://x>
Thank you so much for the quoting from
:help :sort
- was trying to sorting URLs but kept forgetting to specifyr
at the end, and the results made no sense, driving me crazy...