Re: substitute in a selection
Hi,
how can I substitute text in a selection, instead of the entire page?
Thanks
Last edited by kroiz (2006-11-21 13:40:13)
You are not logged in. Please login or register.
Hi,
how can I substitute text in a selection, instead of the entire page?
Thanks
Last edited by kroiz (2006-11-21 13:40:13)
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:
'<,'>s/foo/goo/g
Hope this helps
Nando
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.
Thanks alot guys.
Currently installed 3 official extensions. Copyright © 2003–2009 PunBB.
[ Generated in 0.041 seconds, 9 queries executed ]