Hi vim_use!

On So, 13 Mai 2012, Christian Brabandt wrote:

> Hi meino.cramer!
> 
> On So, 13 Mai 2012, [email protected] wrote:
> 
> > Before sort
> > 
> >     Is there a way to sort bdacefhgjilnkm?
> >                            a            b                           
> > 
> > After sorting the marked portion(a<->b):
> > 
> >     Is there a way to sort abcdefghijklmn?
> > 
> > Or in other words:
> > 
> > Everything of the marked portion is sorted alphbetically (ASCII-based)
> > character by character.
> > 
> > But: I wanted to this via "vim-power" and no to use vim as a "shell"
> > to call python (or whatelse) scripts.
> > 
> > For that I dont need vim...for that I have zsh.
> 
> Well, you can probably script something. Since I have written the 
> NrrwRgn plugin[1], I would use it, e.v. select your text, press \nr to 
> open the selected range in a new window, split the letters on new lines, 
> (:%s/./&\r/g), sort the lines (:%sort), join them back together 
> (:%s/\(.\)\n/\1/g), and :wq the new window. The result will then be 
> merged back into the original buffer.
> 
> [1]http://www.vim.org/scripts/script.php?script_id=3075

Alternatively, here is a mapping you could use:
:nnoremap <f2> :let @"=join(sort(split(@",'\zs')), '')<cr>gvp

First visually select the characters you want to sort, then yank them 
into the default register. then press <f2>

regards,
Christian
-- 

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to