Re: Sort within VI with parameters

Samir Faci <[email protected]> Fri, 24 Jun 2011 09:53:38 -0500
Newsgroups gmane.org.user-groups.luni.tech
Message-ID <[email protected]>
the other way of doing this.. which sort of works is using visual mode.

ie.

V  highlight the entire section
type !sort -t '|' -k2,2   (ie. it'll print out :'<,'>!sort -t '|' -k2,2

naturally if you have a file with 200000 records, this gets a bit
tedious, but then at that point, I would simply drop to a shell
and just use awk/grep/sed from CLI directly.

reference: http://www.oualline.com/vim-cook.html#sorting



On Fri, Jun 24, 2011 at 9:00 AM, Keith T. Garner <[email protected]> wrot=
e:
> This is way overkill, but it DOES work this way:
>
> :%!sh -c "sort -t '|' -k2,2"
>
> Also, the last form in Colin's mail had worked for me on the mac's defaul=
t vi, haven't had a chance to try it in vim yet.
>
>
> On Jun 24, 2011, at 7:46 AM, Jay Strauss wrote:
>
>> Yeah that's what I think too
>>
>> I've tried every incantation ( and yours) with no success
>>
>> Thanks
>> Jay
>>
>> Sent from my iPhone
>>
>> On Jun 23, 2011, at 3:13 PM, [email protected] wrote:
>>
>>>
>>>> I can't figure out the proper incantation
>>>>
>>>> <esc>:%!sort -t| -k2,2
>>>
>>> It looks like your field separator is getting interpreted as a
>>> shell pipe character. Try escaping it like so:
>>>
>>> <esc>:%!sort -t\| -k2,2
>>>
>>> Or perhaps quoting it:
>>>
>>> <esc>:%!sort -t'|' -k2,2
>>>
>>> Colin
>>>
>>> --
>>> Linux Users Of Northern Illinois (Chicago) - Technical Discussion
>>> http://luni.org/mailman/listinfo/luni
>> --
>> Linux Users Of Northern Illinois (Chicago) - Technical Discussion
>> http://luni.org/mailman/listinfo/luni
>
> --
> =A0Keith T. Garner =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 [email protected]
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"Make no little plans; they have no magic =
to
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 stir men's blood." - Daniel H. Burnham
>
> --
> Linux Users Of Northern Illinois (Chicago) - Technical Discussion
> http://luni.org/mailman/listinfo/luni
>



-- =

Samir Faci
*insert title*
fortune | cowsay -f /usr/share/cows/tux.cow

Sent from my non-iphone laptop.
-- =

Linux Users Of Northern Illinois (Chicago) - Technical Discussion =

http://luni.org/mailman/listinfo/luni