diff options
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r-- | src/ex_cmds.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 5ca3dfd07d..66bbb188df 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -408,7 +408,11 @@ ex_sort(eap) goto sortend; } *s = NUL; - regmatch.regprog = vim_regcomp(p + 1, RE_MAGIC); + /* Use last search pattern if sort pattern is empty. */ + if (s == p + 1 && last_search_pat() != NULL) + 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 */ |