Fixes this bug / feature request: When pattern for ":sort" is empty, use last search pattern. Allows trying out the pattern first. (Brian McKee) Created by Martin Toft during Google Summer of Code 2007. *** runtime/doc/change.txt.orig Tue Jul 10 02:48:03 2007 --- runtime/doc/change.txt Tue Jul 10 02:48:05 2007 *************** *** 1571,1576 **** --- 1571,1580 ---- in their original order, right before the sorted lines. + If {pattern} is empty (e.g. // is specified), the + last search pattern is used. This allows trying out + a pattern first. + Note that using ":sort" with ":global" doesn't sort the matching lines, it's quite useless. *** src/ex_cmds.c.orig Tue Jul 10 02:39:26 2007 --- src/ex_cmds.c Tue Jul 10 02:29:33 2007 *************** *** 408,414 **** goto sortend; } *s = NUL; ! regmatch.regprog = vim_regcomp(p + 1, RE_MAGIC); if (regmatch.regprog == NULL) goto sortend; p = s; /* continue after the regexp */ --- 408,418 ---- goto sortend; } *s = NUL; ! /* Use last search pattern if sort pattern is empty. */ ! if (s == p + 1 && last_search_pat() != NUL) ! regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC); ! else ! regmatch.regprog = vim_regcomp(p + 1, RE_MAGIC); if (regmatch.regprog == NULL) goto sortend; p = s; /* continue after the regexp */