Thursday, April 23, 2015

Re: norm in a global command not working in script

On 2015-04-23 02:21, av wrote:
>>>> :g/^\w/-j
>>>>
>>>> where "-j" is the Ex command to, on the previous line ("-"),
>>>> join it with the next line (":help :j").
>>
>> Instead of what I wrote:
>> g, = ,-j
>> it should be
>> g!, = ,-j
>> which is working fine with the sample data.
>>
>> Many thanks Tim!!

Glad it seems to be doing what you needed.

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

In theory any(*) Ex command should work fine here, including
:exec and :normal for example:

:g/^/exec '.w '.getline('.').'.txt'

will write each line in the current file to its own file,
named "{that line's contents}.txt"

So without the actual commands that you tried, it's hard to
say what failed.

-tim

(*) You can't nest :g or :v commands, so it's really "any ex
command except other :g/:v commands"

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