Thursday, April 23, 2015

Re: norm in a global command not working in script

Le jeudi 23 avril 2015 09:34:43 UTC+2, av a écrit :
> Le jeudi 23 avril 2015 08:58:09 UTC+2, av a écrit :
> > Le vendredi 17 avril 2015 01:49:38 UTC+2, Tim Chase a écrit :
> > > On 2015-04-16 15:58, av wrote:
> > > > g,^\w,exe '.,.-1 join'
> > > >
> > > > Is it possible to achive the g,something,norm kJ but with ex
> > > > command instead, maybe it will work for me.
> > >
> > > A couple observations:
> > >
> > > - you're using :exe but don't really need to
> > >
> > > - your range is backwards
> > >
> > > I suspect that you can accomplish what you want with
> > >
> > > :g/^\w/-j
> > >
> > >
> > > where "-j" is the Ex command to, on the previous line ("-"), join it
> > > with the next line (":help :j").
> > >
> > > -tim
> >
> > Hi Tim,
> >
> > It is not working also. So I have this function with your -j method:
> >
> > fu! g:Gon()
> > bd! test.txt
> > exe 'split c:/temp/test.txt'
> > g, = ,-j
> > endfu
> >
> > And I have this test text here:
> >
> > --
> >
> > MySingleLineTextField = testalsdkflkasdf
> > MyMultilineTextField = alsdfjlasdjflksdjlf
> > asldjflaskdfjasdjflasjkdf
> > asdlkflaskdfjasdjfjasdkfjklsd
> > alsdflkasdfjksdjklf
> >
> > MySingleLineTextField = 2308230982309weofsf
> > MyMultilineTextField = asljf9u3f92jfj23fio32jfio3j2iojf23
> > asdfisdjafjs09fjsdf09sdj0f
> > as0dfj0asdj0fasd0j9fas09dfj09sdj0f9sdjf
> >
> > --
> >
> > Then I call using: call g:Gon()
> >
> > And the result is:
> >
> > --
> >
> > MySingleLineTextField = testalsdkflkasdf MyMultilineTextField = alsdfjlasdjflksdjlf
> > asldjflaskdfjasdjflasjkdf
> > asdlkflaskdfjasdjfjasdkfjklsd
> > alsdflkasdfjksdjklf
> > MySingleLineTextField = 2308230982309weofsf MyMultilineTextField = asljf9u3f92jfj23fio32jfio3j2iojf23
> > asdfisdjafjs09fjsdf09sdj0f
> > as0dfj0asdj0fasd0j9fas09dfj09sdj0f9sdjf
> >
> > --
> >
> > The expected results would be that all text that have not " = " would be joined with the previous line with " = " in it, like this:
> >
> > --
> >
> > MySingleLineTextField = testalsdkflkasdf
> > MyMultilineTextField = alsdfjlasdjflksdjlf asldjflaskdfjasdjflasjkdf asdlkflaskdfjasdjfjasdkfjklsd alsdflkasdfjksdjklf
> >
> > MySingleLineTextField = 2308230982309weofsf
> > MyMultilineTextField = asljf9u3f92jfj23fio32jfio3j2iojf23 asdfisdjafjs09fjsdf09sdj0f as0dfj0asdj0fasd0j9fas09dfj09sdj0f9sdjf
> >
> > --
> >
> > Do you obtain this result?
> >
> > Thank you,
> >
> > Alexandre
>
> Hi Tim,
>
> Sorry, it is working fine. I misused your command by inverting the match.
>
> Instead of what I wrote:
> g, = ,-j
> it should be
> g!, = ,-j
> which is working fine with the sample data. I still need to try it with the full data but other commands like the norm kJ didn't format the test data correctly when the file was close and reopened just before the command.
>
> But with your command it is working nice in the test function:
>
> fu! g:Gon()
> bd! test.txt
> exe 'split c:/temp/test.txt'
> g!, = ,-j
> endfu
>
> Many thanks Tim!!
>
> Alexandre

Hi,

Just another quick related question: the -j seems to work but still how could I execute any other exe command inside the global. Something like g!/ = /exe 'mycommand' didn't work nor g!/ = /norm something. Actually the command ran but the results where erroneous for me (gvim 7.3 on windows).

I ask this because this command construct would be very powerful to accomplish many things.

Thank you,

Alexandre

--
--
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/d/optout.

No comments:

Post a Comment