You could try the yanking the visual selection before starting the ex command:
y:%s/<c-r>"/foo/g
y
: yank the visual selection
:%s/
: start the ex command
- Ctrl+r ": insert the last yanked/deleted text
/foo/g
: the remaining ex command
Note that it won't escape the dot -- you will probably need to write a custom function to achieve that (if you intend to follow this approach, you could use the "PatternsOnText" plugin as a starting point).
One simple solution, using \V
as suggested by Kent to avoid the need to escape special characters, is the following mapping:
vnoremap <F4> y:%s/\V<c-r>"//g<left><left>
If you are trying to reduce the number of key strokes you should consider the following (specially if you intend to change a small number of matches):
y/\V<c-r>"<cr>cgnfoo<esc>..
y
: yank and exit visual selection
/\V
Ctrl+r"Enter: use the last yanked text to start a search
cgn
: change the next match
- fooEsc: insert foo and exit insert mode
.
: repeat last change
without typing %s/amet\./foo/g
? Without typing it at all (not using a substitute command) or not typing it entirely (injecting the content of the selection in the command)?:%s/..
part would be great.*
on amet. word, it selects all occurances of amet. then run this command:%s//foo
; there is no need to type amet. again and eveng
flag.<c-r><c-a>
will insert the WORD under the cursor..
toisk
and using*
will select words contain.
;set isk+=.