Vim functions which take ranges take line ranges. So *:'<,'>s/A/X/g* —
which would be the ensuing command — would start from "the beginning line
of the selection" to "the last line of the selection". A substitution on
that will do what is expected.

For your case, you should try a more targeted regex. I came up with
*:'<,'>s/\w\+
\zsAAA/XXX* but my regex-fu is not at black belt yet.

Hope this helps

On Wed, Jan 10, 2024 at 10:23 PM Eike Rathke <[email protected]> wrote:

> Hi Igor,
>
> On Wednesday, 2024-01-10 00:48:12 -0800, Igor wrote:
>
> > I did:
> > My cursor after opening a file is at first character in top left as
> > expected.
> > 1. Move 4 characters to the right: 4l
> > 2. To get into visual block: CTRL+V
> > 3. Select current and line bellow: j
> > 4. Select text to tend of line: $
> > 5. Now second column is selected. I would like do the substitution with:
> > :s/A/X/g
> > And now I get:
> > XXX XXX
> > XXX XXX
> >
> > How to substitute characters inside visual block?
>
> Instead, with the block selection still intact, simply press s for
> substitute and enter XXX and then Escape or Ctrl+[
> It will substitute on all lines of the selected block.
>
>   Eike
>
> --
> OpenPGP/GnuPG encrypted mail preferred in all private communication.
> GPG key 0x6A6CD5B765632D3A - 2265 D7F3 A7B0 95CC 3918  630B 6A6C D5B7 6563
> 2D3A
> Use LibreOffice! https://www.libreoffice.org/
>
> --
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vim_use/ZZ8Y-Rk-qY2RDF-U%40kulungile.erack.de
> .
>

-- 
-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/CAOmRJrdGuKpmoziM3YVigr91%2B8v9p7ThWXOAQnsSrqFK2Sh1AQ%40mail.gmail.com.

Reply via email to