Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
change all files
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
vicky b  
View profile  
 More options Nov 6 2012, 9:01 am
From: vicky b <vickyb2...@gmail.com>
Date: Tue, 6 Nov 2012 19:30:32 +0530
Local: Tues, Nov 6 2012 9:00 am
Subject: change all files

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

--
*Thanks & Regards
 Vickyb

*


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Chase  
View profile  
 More options Nov 6 2012, 9:18 am
From: Tim Chase <v...@tim.thechases.com>
Date: Tue, 06 Nov 2012 08:18:18 -0600
Local: Tues, Nov 6 2012 9:18 am
Subject: Re: change all files
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vicky b  
View profile  
 More options Nov 7 2012, 8:07 am
From: vicky b <vickyb2...@gmail.com>
Date: Wed, 7 Nov 2012 18:37:05 +0530
Local: Wed, Nov 7 2012 8:07 am
Subject: 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\u0 E01\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\u0 E01\u0E29\u0E32

that i want lines whic have \u0E15 these kind of stsring others i want to
delete

--
*Thanks & Regards
 Vickyb

*


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Chase  
View profile  
 More options Nov 7 2012, 8:56 am
From: Tim Chase <v...@tim.thechases.com>
Date: Wed, 07 Nov 2012 07:56:29 -0600
Local: Wed, Nov 7 2012 8:56 am
Subject: Re: change all files
On 11/07/12 07:07, vicky b wrote:

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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vicky b  
View profile  
 More options Nov 8 2012, 7:20 am
From: vicky b <vickyb2...@gmail.com>
Date: Thu, 8 Nov 2012 17:23:51 +0530
Local: Thurs, Nov 8 2012 6:53 am
Subject: Re: change all files

THanks Tim dont get me wrong on this i have another query hope u wont mind,

  now i have 4 file where each file has key,value data , now i want to
compare all the files get all the lines which have common keys in it , say

 file1            file2                     file3           file
tim,chase    tom,someting    tom,wright   chase,w
tom,jerry      vinay,b              sachin,b      tom,m

out put would be
tom,chase
tom,jerry
tom,wright
tom,m

is this  possible in vim

--
*Thanks & Regards
 Vickyb

*


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marcin Szamotulski  
View profile  
 More options Nov 8 2012, 8:11 am
From: Marcin Szamotulski <msza...@gmail.com>
Date: Thu, 8 Nov 2012 13:10:48 +0000
Local: Thurs, Nov 8 2012 8:10 am
Subject: Re: change all files
On 17:23 Thu 08 Nov     , vicky b wrote:

Hi,

I guess you can use the :g command (":help :g"):

:argdo :g/^tom/#

:argdo  - do the command for every file in the arg list
:g      - run the # command (:help :#) for every line matching the pattern between /.../

If you want to put the output into another buffer you can do redirect it
to a register and paste it somewhere:

:redir @a
:argdo :g/^tom/
:redir end

Now you can paste the output using: "ap in normal mode.

If there is no command specified for the :g command it just prints the
line (:# prints the line with the line number).

Best,
Marcin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Chase  
View profile  
 More options Nov 8 2012, 12:26 pm
From: Tim Chase <v...@tim.thechases.com>
Date: Thu, 08 Nov 2012 11:26:36 -0600
Local: Thurs, Nov 8 2012 12:26 pm
Subject: Re: change all files
On 11/08/12 05:53, vicky b wrote:

> THanks Tim dont get me wrong on this i have another query hope u wont mind,

Nope...it's a pretty friendly list.

>   now i have 4 file where each file has key,value data , now i want to
> compare all the files get all the lines which have common keys in it , say

>  file1            file2                     file3           file
> tim,chase    tom,someting    tom,wright   chase,w
> tom,jerry      vinay,b              sachin,b      tom,m

> out put would be
> tom,chase
> tom,jerry
> tom,wright
> tom,m

> is this  possible in vim

I'm not sure I fully understand what you want here.  I don't see any
obvious transformation from your 4 input files to the output you
request, so without a better understanding of what you want, it's
hard to produce a solution.

Operating across multiple files in vim is not always the easiest
thing to do, so I'd suggest a quick external script in
bash/perl/python/ruby.

-tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Little  
View profile  
 More options Nov 9 2012, 12:04 am
From: John Little <John.B.Lit...@gmail.com>
Date: Thu, 8 Nov 2012 21:04:29 -0800 (PST)
Local: Fri, Nov 9 2012 12:04 am
Subject: Re: change all files

How about

1)  Concatenate and sort all the files, either outside vim and load them into vim, or in, say

    :for x in expand('file*',0,1) | exe 'r ' . x | endfor | sort

2) Decorate those of interest, say

    :%s/^\(\(.\{-}\),.*\)\n\(\2,.*\)$/\1@!@\r\3@!@/

3) Delete the uninteresting:

    :v/@!@/d

4) Remove the decorations:

    :%s/@!@//

Steps 2,3,4 could be combined using a look behind regex, I imagine.

Regards, John


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vicky b  
View profile   Translate to Translated (View Original)
 More options Nov 14 2012, 7:21 am
From: vicky b <vickyb2...@gmail.com>
Date: Wed, 14 Nov 2012 17:50:55 +0530
Local: Wed, Nov 14 2012 7:20 am
Subject: Re: change all files

currently i am java developers who is addicted to eclipse( java ide),
notepad++
would it help me if i start learning vim consider it steep learning curve
may not be now but would it help me in the long run

On Fri, Nov 9, 2012 at 10:34 AM, John Little <John.B.Lit...@gmail.com>wrote:

--
*Thanks & Regards
 Vickyb

*


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Fritz  
View profile  
 More options Nov 14 2012, 9:37 am
From: Ben Fritz <fritzophre...@gmail.com>
Date: Wed, 14 Nov 2012 06:37:41 -0800 (PST)
Local: Wed, Nov 14 2012 9:37 am
Subject: Re: change all files

On Wednesday, November 14, 2012 6:21:25 AM UTC-6, vicky b wrote:
> currently i am java developers who is addicted to eclipse( java ide), notepad++  
> would it help me if i start learning vim consider it steep learning curve may not be now but would it help me in the long run 

Possibly; it depends on your editing style. My guess is "yes". Since you use both Eclipse and Notepad++, I'm guessing you like some of the developer tools in Eclipse but not the text editor.

Vim is not a very good IDE by itself but is an EXCELLENT text editor. And the eclim plugin for Eclipse and Vim lets you access many of the Eclipse developer tools you like from within Vim:

http://eclim.org

Next time please start a new thread rather than responding to an old one for a new topic like this.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »