Wednesday, November 7, 2012

Re: change all files

On 11/07/12 07:07, vicky b wrote:
> I was able to do that but i have some unwanted lines in a file
>
> i just want line that have a pattern , below is the file
>
> #Generated by ResourceBundle Editor
> # en Resource Bundle
> #
> # filename: FormsNRefsPortletResource_en.properties
> # Portlet Info resource bundle example
> Matches , \u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A
> Select , \u0E40\u0E25\u0E37\u0E2D\u0E01
> choice1Label ,
> \u0E40\u0E02\u0E49\u0E32\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E23\u0E31\u0E01\u0E29\u0E32
>
>
> desired file should be like
>
> Matches , \u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A
> Select , \u0E40\u0E25\u0E37\u0E2D\u0E01
> choice1Label ,
> \u0E40\u0E02\u0E49\u0E32\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E23\u0E31\u0E01\u0E29\u0E32
>
>
> that i want lines whic have \u0E15 these kind of stsring others i want to
> delete

Well, there are a couple options, again using ":argdo" to iterate
over all the files. If you want to keep lines that contain
"backslash u hex-digit hex-digit hex-digit hex-digit", you can do

:set hidden
:argdo v/\\u\x\x\x\x/d

then review your changes and either save/abandon the changes.

Alternatively, if you have your original file and just want to keep
the "=" lines even if they don't have hex digits on them (might be
integers or something else?), you can preprocess with

:argdo v/=/d

to delete all the lines that don't contain an "=". You can then run
the previously-provided command to change the "=" to ",".

If you just want to delete those lines starting with a hash, you can use

:argdo g/^\s*#/d

to delete them.

-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

No comments: