Wednesday, December 14, 2016

Re: How can I do date format convertion?

On 2016-12-14 18:31, Carfield Yim wrote:
> 20150204
> 20150304
> 20150309
> 20150323
> 20150331
> 20150416
> 20150608
>
> I would like to change it to
>
> 2015.02.04
> 2015.03.04
> 2015.03.09
> 2015.03.23
> 2015.03.31
> 2015.04.16
> 2015.06.08
>
> How can I do that?

Capture them and reformat them as you see fit:

:%s/\(\d\{4}\)\(\d\{2}\)\(\d\{2}\)/\1.\2/.\3/

Or, you can use visual block mode (control+V by default) and select
the two month columns. Press "I" followed by a period followed by
<esc> to insert the first period. Type "gv" to re-visualize that
block, pressing "A" followed by a period followed by <esc> to add the
second period.

Vim gives you lots of nice ways to do these sorts of things. :-)

-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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment