On Tue, Jun 24, 2014 at 05:52:10AM -0700, Axel Bender wrote:
> @Ben Fritz
>
> As I see it, you can use a search pattern (r) for certain tasks, but it isn't
> a solution. Please, consider the following sample:
>
> 19500623 # ÖST # USA # Curitiba
> 19500621 # ÖST # MEX # Macapa
> 19500825 # AND # FRA # Curitiba
> 19500620 # MEX # BRA # Recife
> 19500625 # BEL # FRA # Curitiba
>
> sort -t# -k4r -k1 sample : Reverse sort on column 4, then sort on column 1
>
> 19500620 # MEX # BRA # Recife
> 19500621 # ÖST # MEX # Macapa
> 19500623 # ÖST # USA # Curitiba
> 19500625 # BEL # FRA # Curitiba
> 19500825 # AND # FRA # Curitiba
>
> I see no way to accomplish this in vim using :sort (lest you would write a
> VimL script).
I have achieved this with +python3 support. It's ugly, but it works on
Windows without hunting for some binary that's hard to find :-)
:py3 import vim
:'<,'>py3 vim.current.range[:] = sorted(sorted(vim.current.range, key=lambda x:
x.split(' # ')[0]), key=lambda x: x.split(' # ')[3], reverse=True)
You can use +python (Python 2) too, but you'll have to convert between
str and unicode to sort by character instead of the byte value. Maybe it
can be done easier with +perl or +ruby.
--
Best regards,
lilydjwg
Linux Vim Python 我的博客:
http://lilydjwg.is-programmer.com/
--
A: Because it obfuscates the reading.
Q: Why is top posting so bad?
--
--
You received this message from the "vim_dev" 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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.