Tuesday, April 27, 2010

Re: A 'visible within the window' range?

Hi,

Duane Johnson wrote:
>
> So the % symbol is a special range that means 'the whole file'. Is
> there a similar special symbol that means 'what is visible in the
> window'?
>
> For example, say I can see three instances of the word 'abracadabra'
> on the screen. I want to change them to 'wizard' but don't want to
> affect any other parts of the file. Is there a way to do this without
> entering visual mode? If not, is there a way to select all visible
> lines so that (in visual mode) I can do:
>
> :*s/abracadabra/wizard/r

as Tim already wrote * might be a shorthand for the range '<,'> . If
you don't need this shorthand you can use this mapping to replace the
asterisk with the line number of the first and last line of the current
window

cmap <expr> * (getcmdpos() == 1) ? line('w0') . ',' . line('w$') : '*'

This replaces the asterisk only if it's the first character on the line.
Of course you can also use any other key for this.

Regards,
Jürgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)

--
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

No comments:

Post a Comment