(Move categories to tip template) |
(Remove html character entities) |
||
Line 23: | Line 23: | ||
<pre> |
<pre> |
||
− | command! -bang Ls redir @" | silent ls |
+ | command! -bang Ls redir @" | silent ls<bang> | redir END | echo " " | |
\ perl { |
\ perl { |
||
\ my $msg=VIM::Eval('@"'); |
\ my $msg=VIM::Eval('@"'); |
||
Line 43: | Line 43: | ||
\ VIM::Msg($msg); |
\ VIM::Msg($msg); |
||
\ } |
\ } |
||
− | \ |
+ | \ <CR> |
</pre> |
</pre> |
||
==Comments== |
==Comments== |
||
− | |||
− | ---- |
Revision as of 23:38, 29 September 2008
Tip 976 Printable Monobook Previous Next
created August 20, 2005 · complexity intermediate · author Suresh Govindachar · version 6.0
This tip requires Perl and overwrites the unnamed register.
The output of :ls is sorted by buffer number.
The following command results in a user defined command named :Ls (all user defined commands need to start with a capital letter).
The output of :Ls is the same as the output of :ls except that the output is sorted by buffer name.
Here's the command which you can place in your vimrc:
command! -bang Ls redir @" | silent ls<bang> | redir END | echo " " | \ perl { \ my $msg=VIM::Eval('@"'); \ my %list=(); \ my $key, $value; \ while($msg =~ m/(.*?line\s+\d+)/g) \ { \ $value = $1; \ $value =~ m/"([^"]+)"/; \ $key = $1; \ ($^O =~ /mswin/i) and $key = lc($key); \ $list{$key} = $value; \ } \ my $msg = ''; \ for $key (sort keys %list) \ { \ $msg .= "$list{$key}\n"; \ } \ VIM::Msg($msg); \ } \ <CR>