Vim Tips Wiki
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
FANDOM
Explore
Current Wiki
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Vim Tips Wiki
1,649
pages
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
Editing
List buffers sorted by name
Back to page
Edit
Edit source
View history
Talk (0)
Edit Page
List buffers sorted by name
We recommend that you
log in
before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your
Watchlist
.
Creating an account
is quick and free.
The edit appears to have already been undone.
Anti-spam check. Do
not
fill this in!
{{review}} {{TipImported |id=976 |previous=975 |next=977 |created=2005 |complexity=intermediate |author=Suresh Govindachar |version=6.0 |rating=9/5 |category1= |category2= }} This tip requires Perl and overwrites the unnamed register. The output of <code>:ls</code> is sorted by buffer number. The following command results in a user defined command named <code>:Ls</code> (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: <pre> 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> </pre> ==Comments==
Summary:
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Navigation
(
view source
)
Template:Review
(
view source
)
Template:TipImported
(
view source
)
Follow on IG
TikTok
Join Fan Lab