Re: substitute in a selection

how can I substitute text in a selection, instead of the entire page?


Last edited by kroiz (2006-11-21 13:40:13)


Re: substitute in a selection

You can use the visual mode to highlight the area where you want to do the replacement (pressing v or V when in normal mode) and then pressing : to enter in command mode, which automatically will put for you the markers for the beginning and end of the selection, and after that you can just type the substitute command you want. For example, to change foo for goo in a selection type this:


Hope this helps



Re: substitute in a selection

Nando, thanks for helping out.

Kroiz, Nando's explanation has it. Just for clarification, you can only do this in a range of lines, as ex commands only understand ranges based on lines. '< and '> refer to the 'last visual selection start' and 'last visual selection end' marks, which ViEmu maintains all the time (you can jump to them by using '< or `< at any moment), and the 'gv' command uses them to go back to visual mode with the last range there was.

As Nando said, you'll see how just pressing ':' in visual mode brings up the ex command line with :'<,'> already typed in, so that whatever you type will be applied to the current selection instead of the command's default extension.


Re: substitute in a selection

Thanks alot guys.