how to quickly change block data order

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how to quickly change block data order

Sand Glass
I have the following situation. I want to change it
####################
               b390 62b3 9062 b390 61b2
8f61 b28e 5fb2 8d5d b18c 5aaf 8955 ad86
50ab 834a a97f 45a7 7c3f a579 3aa3 7635
a174 30a0 722d 9e6f 2a9e 6e27 9d6c 249c
6b23 9b6b 219b 6a20 9b69 1f9b 681f 9a68
1e9a 681d 9a68 1d9a 681d 9a67 1d99 671d
9967 1d9a 671d 9a68 1d9a 681d 9a68 1d9a
681d 9a68 1d9a 681d 9a68 1d9a 681d 9a68
1d9a 681d 9a68 1d9a 681d 9a68 1d9a 681d
bda5 8dbd a58d                        
####################
to
####################
b390 62b3 9062 b390 61b2 8f61 b28e 5fb2
8d5d b18c 5aaf 8955 ad86 50ab 834a a97f
45a7 7c3f a579 3aa3 7635 a174 30a0 722d
9e6f 2a9e 6e27 9d6c 249c 6b23 9b6b 219b
6a20 9b69 1f9b 681f 9a68 1e9a 681d 9a68
1d9a 681d 9a67 1d99 671d 9967 1d9a 671d
9a68 1d9a 681d 9a68 1d9a 681d 9a68 1d9a
681d 9a68 1d9a 681d 9a68 1d9a 681d 9a68
1d9a 681d 9a68 1d9a 681d bda5 8dbd a58d
####################
Accually there are many lines (ten thousand more) data need to change their order. How can I do it?

--
--
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 the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to quickly change block data order

arocker
> I have the following situation. I want to change it
> ####################
>                b390 62b3 9062 b390 61b2

> Accually there are many lines (ten thousand more) data need to change
> their order. How can I do it?
>

It's not obvious from the example what transformation you're trying to
achieve. Have you thought of using sed, or another streaming tool, rather
than a static text editor like vim?

--
--
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 the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to quickly change block data order

Gary Johnson-4
In reply to this post by Sand Glass
On 2017-09-21, Sand Glass wrote:

> I have the following situation. I want to change it
> ####################
>                b390 62b3 9062 b390 61b2
> 8f61 b28e 5fb2 8d5d b18c 5aaf 8955 ad86
> 50ab 834a a97f 45a7 7c3f a579 3aa3 7635
> a174 30a0 722d 9e6f 2a9e 6e27 9d6c 249c
> 6b23 9b6b 219b 6a20 9b69 1f9b 681f 9a68
> 1e9a 681d 9a68 1d9a 681d 9a67 1d99 671d
> 9967 1d9a 671d 9a68 1d9a 681d 9a68 1d9a
> 681d 9a68 1d9a 681d 9a68 1d9a 681d 9a68
> 1d9a 681d 9a68 1d9a 681d 9a68 1d9a 681d
> bda5 8dbd a58d                        
> ####################
> to
> ####################
> b390 62b3 9062 b390 61b2 8f61 b28e 5fb2
> 8d5d b18c 5aaf 8955 ad86 50ab 834a a97f
> 45a7 7c3f a579 3aa3 7635 a174 30a0 722d
> 9e6f 2a9e 6e27 9d6c 249c 6b23 9b6b 219b
> 6a20 9b69 1f9b 681f 9a68 1e9a 681d 9a68
> 1d9a 681d 9a67 1d99 671d 9967 1d9a 671d
> 9a68 1d9a 681d 9a68 1d9a 681d 9a68 1d9a
> 681d 9a68 1d9a 681d 9a68 1d9a 681d 9a68
> 1d9a 681d 9a68 1d9a 681d bda5 8dbd a58d
> ####################
> Accually there are many lines (ten thousand more) data need to
> change their order. How can I do it?

It appears that you want to change the formatting of those lines,
not their order.  One way to do that is the following, which assumes
for simplicity that there is nothing in the buffer but your data.

Get rid of the indentation of the first line:

    gg0dw

Clear any 'formatoptions':

    :set fo=

Set the 'textwidth' to the width of your data:

    :set tw=39

Fill all the lines to that 'textwidth':

    gggqG

See also:

    :help gq

Regards,
Gary

--
--
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 the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to quickly change block data order

Tim Chase
On 2017-09-21 08:08, Gary Johnson wrote:
> Get rid of the indentation of the first line:
>
>     gg0dw

Or either of the following

  gg<G
  :%le

>     :set fo=
>     :set tw=39
>     gggqG

If you prefer to do it with standard *nix tools outside of vim, you
can use

  sed 's/^\s*//' in.txt | fmt -w 40 > out.txt

The `sed` strips off the leading whitespace while `fmt` does the
heavy lifting/reformatting.

-tim


--
--
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 the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.