sorting lines by two first virtual column

14 views
Skip to first unread message

Ni Va

unread,
Jan 30, 2021, 3:41:51 AM1/30/21
to vim_use
Hi,

I would like to sort lines by order ascendant by the alphabetical value of the two first columns.

 2021/01/13 15:05:52.417 FOO
 2021/01/13 15:05:52.417 FOO
 2021/01/13 15:05:52.417 FOO
 2021/01/13 15:06:05.151 FOO
 2021/01/13 15:06:05.151 FOO
 2021/01/13 15:06:05.151 FOO
 2021/01/13 15:06:05.151 FOO
 2021/01/13 15:06:05.151 FOO
 2021/01/13 15:06:08.354 FOO
 2021/01/13 15:06:08.354 FOO
 2021/01/13 15:06:08.354 FOO
 2021/01/13 15:06:05.151 BAR
 2021/01/13 15:06:05.151 BAR
 2021/01/13 15:06:05.151 BAR
 2021/01/13 15:06:05.151 BAR
 2021/01/13 15:06:05.151 BAR
 2021/01/13 15:06:05.151 BAR
 2021/01/13 15:06:08.354 BAR
 2021/01/13 15:06:08.354 BAR
 2021/01/13 15:06:08.354 BAR



rwmit...@gmail.com

unread,
Jan 30, 2021, 8:09:35 AM1/30/21
to vim_use
This worked for me.  Put the cursor on the first line and type:
  !}sort

See the unix man page on sort for any additional options you may want to through at it.
The !  tells vim you want want process a block of text thru an external program
The } tells vim to send this paragraph
'sort' is the command to do the filtering/processing.

that's my basis understanding of what is happening.

aro...@vex.net

unread,
Jan 30, 2021, 11:25:56 AM1/30/21
to vim...@googlegroups.com

>
> I would like to sort lines by order ascendant by the alphabetical value of
> the two first columns.
>

Are you on Windoes, or an *nix?

(The example file would be more useful if the input was not in order.)

rwmit...@gmail.com

unread,
Jan 30, 2021, 1:27:41 PM1/30/21
to vim_use
The input isn't it order.  The lines ending in BAR should get intermixed with FOO.

Ni Va

unread,
Jan 30, 2021, 1:58:26 PM1/30/21
to vim_use
I have done that kind of sort from within Vim : sort /^.\{8}\zs.\{15}\ze/ r

But it ignores stamped date hour and not  two first columns >> then do the same job.

Ni Va

unread,
Jan 30, 2021, 2:40:12 PM1/30/21
to vim...@googlegroups.com
Oh so Sorry. Windows 10.

--
--
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

---
You received this message because you are subscribed to a topic in the Google Groups "vim_use" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/jmelxbd3RV4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_use+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/4a152c29510c7feb462a4dd53ca06f69.squirrel%40webmail.vybenetworks.com.
Reply all
Reply to author
Forward
0 new messages