Wednesday, November 7, 2012

Re: change all files

Thanks tim that  did help 

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


On Tue, Nov 6, 2012 at 7:48 PM, Tim Chase <vim@tim.thechases.com> wrote:
On 11/06/12 08:00, vicky b wrote:
> HI I have list of files in a dir, each file has a key=value pair
> kind of entries so it basically a  prop file .I want to  change
> all they key=value in all  file to key,value is it possible using
> vim ,    sorry if it is off topi


Depending on the complexity, it could be as simple as

  vim *.txt
  :argdo %s/=/,/e|w

or slightly less recklessly,

  vim *.txt
  :set hidden
  :argdo %s/=/,/e
(survey the changes)
  :xa       " if they're good save & quit all, or
  :qa!      " if they're bad, abandon all changes

The :s command could be made more complex to tighten the
requirements, something like

  %s/^\w\+\zs\s*=\s*\ze\</,/e

which ensures that there's a "word" at the beginning of the line,
followed by some optional whitespace (that will removed), the equals
sign (which will get changed to a comma) followed by more optional
whitespace (that will also get removed), followed by the start of a
word.  This can be tweaked depending on the particulars of your
use-case.

-tim





--
Thanks & Regards
 Vickyb



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