You can record a macro to do this.
With a visual selection, do the following:
q q - write macro to q register
c - change the content of the visual highlight
$ $ Esc - insert $$
P - paste the source text between $ s (pay attention to its capital P)
q - stop macro recording
From now on, you can make your visual choice and simply run @ q .
Matthew Strawbridge
source share