On Monday, December 31, 2012 9:23:43 PM UTC-6, Jack Gates wrote:
> I found this
>
>
>
> You have to use normal to execute normal mode commands in command mode:
>
>
>
> :g/searchString/ normal ^A
>
>
>
> Note that you have to press Ctrl-V Ctrl-A to get the ^A character.
>
>
>
> I have
>
>
>
> :s@\d\+@\=submatch(0) +1@g
>
>
>
> to do what I want.
>
>
>
> But can CTRL-A or ^A be used in a :s@search@replace@g command? I
>
> haven't found anything that shows that it can be used that way. I saw
>
> in :help that it can be used in a macro. It seems if it could be used
>
> in a single line search with global replacement at the command line
>
> then it could also be used in a map.
>
I think it should be possible to use in an s command using the expression register and a function wrapping the normal command. But I think the solution you used with submatch() is much better.
It can certainly be used in a mapping as well, where <C-A> is a better notation than a literal ^A character, but either will work. Just remember CTRL-A is a *normal mode* command, and therefore cannot be used directly from the command-line, where your :s command is executed.
--
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
No comments:
Post a Comment