From 9ae4aa07f5b14a7add1b58684513218f46f80767 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Fri, 8 Apr 2011 23:49:31 +0100 Subject: vim-mode: minimal ex-mode tab-completion. Completes provided only the current prefix allows only 1 unique completion. --- vim-mode/vim_mode.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index e247e35..6ce4d22 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -2074,6 +2074,10 @@ sub _parse_mapping_bracket { sub _parse_mapping_reverse { my ($string) = @_; + if (not defined $string) { + _warn("Unable to reverse-map command: " . join('', @ex_buf)); + return; + } # Convert char to . $string =~ s/ //g; $string =~ s/\n//g; @@ -2789,7 +2793,11 @@ sub handle_command_ex { print "Tab pressed" if DEBUG; print "Ex buf contains: " . join('', @ex_buf) if DEBUG; @tab_candidates = _tab_complete(join('', @ex_buf), [keys %$commands_ex]); - + _debug("Candidates: " . join(", ", @tab_candidates)); + if (@tab_candidates == 1) { + @ex_buf = ( split('', $tab_candidates[0]), ' '); + _set_prompt(':' . join '', @ex_buf); + } # Ignore control characters for now. } elsif ($key > 0 && $key < 32) { # TODO: use them later, e.g. completion -- cgit v1.2.3