Friday, August 13, 2010

Re: Limiting the range of a search

On 12/08/10 10:20, James Kanze wrote:
> I'm currently editing some files which contain several more or
> less independent sets of data. At any one time, I'm generally
> working on one, and only one set, delimited as a contiguous
> range of lines. I'd like to limit all of the search commands to
> only consider this range.
>
> I'm aware of using \%<'m and \%>'m in the search string, but
> this has to be entered each search.
>
> My initial idea was to fold the regions before and after the
> range, but this doesn't seem to stop the search, and it
> automatically opens the fold when it finds something in the
> folded text. I want it to not search in the folded text. Is
> there some option to make search ignore folded text, or some
> other way of achieving what I want.
>
> --
> James Kanze
>

In addition to all the answers you already got, here are two more:

1) Visual marking:

The first time, mark your lines in linewise visual mode (i.e. Shift-v at
one end, then move cursor to the other end). Then hitting : will insert

:'<,'>

on the command line, where '<,'> means "from first to last lines of the
latest Visual selection". Don't change that range, but add the
s/from/to/ after it. Thereafter, you can either reinsert the '<,'> or,
if you want something faster, hit gv to "repeat" the latest Visual
selection, after which : will again insert the range.

2) Command-line window

The first time, define the range however you want (visual, marks,
whatever). Thereafter, q: will open the history window, where you can
find the search command (with its range), edit it if necessary, then hit
Enter on the (possibly modified) command to execute it.


Best regards,
Tony.
--
If they can make penicillin out of moldy bread, they can sure make
something out of you.
-- Muhammad Ali

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