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
> 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.
On Tue, Nov 6, 2012 at 7:48 PM, Tim Chase <v...@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.
> 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
On Wed, Nov 7, 2012 at 7:26 PM, Tim Chase <v...@tim.thechases.com> wrote:
> 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
> > 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
> 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.
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:
> 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 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
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: