From 4171a4f3f1749fb59fb0636f4ca7f50910fdf6ac Mon Sep 17 00:00:00 2001 From: Peter Odding Date: Fri, 25 Nov 2011 02:12:24 +0100 Subject: [PATCH] Improve :Note completion (sort candidates by length, ascending) --- autoload/xolox/notes.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autoload/xolox/notes.vim b/autoload/xolox/notes.vim index 1ff6735..e692fb0 100644 --- a/autoload/xolox/notes.vim +++ b/autoload/xolox/notes.vim @@ -6,7 +6,7 @@ " Note: This file is encoded in UTF-8 including a byte order mark so " that Vim loads the script using the right encoding transparently. -let g:xolox#notes#version = '0.15' +let g:xolox#notes#version = '0.15.1' function! xolox#notes#shortcut() " {{{1 " The "note:" pseudo protocol is just a shortcut for the :Note command. @@ -203,7 +203,9 @@ function! xolox#notes#cmd_complete(arglead, cmdline, cursorpos) " {{{1 let prevargs = '^' . xolox#misc#escape#pattern(cmdargs[0 : len(cmdargs) - len(a:arglead) - 1]) call map(titles, 'substitute(v:val, prevargs, "", "")') endif - return titles + " Sort from shortest to longest as a rough approximation of + " sorting by similarity to the word that's being completed. + return reverse(sort(titles, 's:sort_longest_to_shortest')) endfunction function! xolox#notes#user_complete(findstart, base) " {{{1