Thursday, February 28, 2013

Re: vim edit help

First, the explanation.  See the references that Ben Fritz already listed.

/Array<CR>:  Search for the text "Array".  Do not type <CR> literally:  it means hit Enter or Return.
ciw:  Change the word (text object).  You could also use cw or ce (change word or change to end)
dojox.collections.ArrayList:  This will be added to the buffer, since you are in Insert mode after ciw.
<Esc>:  Leave Insert mode.  Do not type it literally.

As for doing it 11 times, I would record a macro, starting before the search command and ending after the :s command.  Roughly, if I want to use the x register for the macro (qx)

qx
/Array<CR>
ciwdojox.collections.ArrayList<Esc>
^w"yye
f(
dib
o<Esc>
p
:s#"[^"]\+",\?\s*#<C-R>y.add(\0);\r#g
q

(Note that I have yanked into the y register instead of typing the word "illness" literally.)  If all of the works, then you can repeat it with

@x
@x
8@x

:help recording

-- 
HTH
Benji Fisher

On Thu, Feb 28, 2013 at 1:59 PM, vicky b <vickyb2084@gmail.com> wrote:
actuall i have to 11 such variables can you please help

var flightDelay = new Array("tvlPlyCp","tvlPlcyCertID","tvlShdIt","tvlConfArlSupId","tvlConfArlcompaid","tvlRepeei","tvlPolRep");
var baggageDelay = new Array("tvlPlyCp","tvlPlcyCertID","tvlShdIt","tvlProIr","tvlConfArlcompaid","tvlRepeei","tvlPolRep");
var baggageLoss = new Array("tvlPlyCp","tvlPlcyCertID","tvlShdIt","tvlProIr","tvlListLost","tvlPolRep");
var tripCacel = new Array("tvlPlyCp","tvlPlcyCertID","tvlShdIt","tvlConfArlcompaid","tvlRrepdsc","tvlPolRep");
var repariation = new Array("tvlPlyCp","tvlPlcyCertID","tvlShdIt","tvlMdRp","tvlRee","tvldc","tvlPolRep","tvladrdc");
var accidentalDisablement = new Array("tvlPlyCp","tvlPlcyCertID","tvlShdIt","tvlMdRp","tvlPolRep","tvladrdc");
var lossOfTravel = new Array("tvlPlyCp","tvlPlcyCertID","tvlShdIt","tvlMhdr","tvlPolRep","tvladrdc");
var secureWallet= new Array("tvlPlyCp","tvlPlcyCertID","tvlShdIt","tvlMhdr","tvlPolRep","tvladrdc");
var others= new Array("tvlPlyCp","tvlPlcyCertID","tvlShdIt","tvlRrepdsc","tvlPolRep","tvladrdc");



On Fri, Mar 1, 2013 at 12:25 AM, vicky b <vickyb2084@gmail.com> wrote:
Can you  please explain more on this section

/Array<CR>
ciwdojox.collections.ArrayList<Esc>


On Fri, Mar 1, 2013 at 12:17 AM, Ben Fritz <fritzophrenic@gmail.com> wrote:
On Thursday, February 28, 2013 12:33:23 PM UTC-6, vicky b wrote:
> HI All,
>
>
>  I have text in below format 
> var illness = new Array("tvlPlyCp","tvlPlcyCertID","tvlShdIt","tvlRepMedEi","tvlMdRp","tvlRrepdsc","tvlPolRep")
>
>
>
>
> i need to convert it 
>
>
>
> var illness = new dojox.collections.ArrayList();
> illness.add("tvlPlyCp");
> illness.add("tvlPlcyCertID")
>
> illness.add("tvlShdIt")
>
>
> illness.add("tvlRepMedEi")
> illness.add("tvlMdRp");
> illness.add("tvlRrepdsc");
> illness.add("tvlPolRep");
>
>
>
> Can anybody help me on this--
> Thanks & Regards
>  Vickyb

Here regular expressions are your friend.

I'd start by changing the "new" line to be correct:
/Array<CR>
ciwdojox.collections.ArrayList<Esc>
f(
dib

Now paste the deleted list of initializers on a new line and put it in the right format:
o<Esc>
p
:s#"[^"]\+",\?\s*#illness.add(\0);\r#g

Done!

All this is untested but it's pretty straightforward so you should be able to fix it.

Help topics so you know what you're doing:
:help text-objects
:help :s
:help /\0
:help /[
:help /\+
:help /\?
:help /\s

--
--
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/groups/opt_out.





--
Thanks & Regards
 Vickyb





--
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
 
---
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/groups/opt_out.
 
 

--
--
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/groups/opt_out.
 
 

No comments:

Post a Comment