feature request: extend search string from a partial match with right arrow key

28 views
Skip to first unread message

Alexey Muranov

unread,
Feb 13, 2012, 4:54:47 PM2/13/12
to vim...@googlegroups.com
Hello,

i am new to this group, let me know if feature requests should be discussed somewhere else.

Here is feature for which i couldn't find a plugin with google, but which looks so natural to me that i think it should be included somehow.

When searching (with "/") and a partial match is highlighted, and the first partial match is a part of the string one is looking for, it would be nice if instead of typing the rest of the search string, one could simply hit the right arrow a number of times to simultaneously extend the highlighted match and complete the search string.

Thanks,

Alexey.

Andy Wokula

unread,
Feb 13, 2012, 6:25:19 PM2/13/12
to vim...@googlegroups.com

You are looking for CTRL-L
It's already there :-)

--
Andy

Benjamin R. Haskell

unread,
Feb 13, 2012, 6:35:41 PM2/13/12
to vim...@googlegroups.com

And here are some mappings to use the arrow keys for the same purpose:

:cmap <expr> <Right> getcmdtype() =~ '[/?]' ? '<C-l>' : '<Right>'
:cmap <expr> <Left> getcmdtype() =~ '[/?]' ? '<BS>' : '<Left>'

:help :cmap
:help :map-<expr>
:help getcmdtype()

--
Best,
Ben

Alexey Muranov

unread,
Feb 14, 2012, 3:17:45 AM2/14/12
to vim...@googlegroups.com

Thanks a lot, i should have googled better.

Alexey.

MacDonald, Stuart

unread,
Feb 14, 2012, 8:53:00 AM2/14/12
to vim...@googlegroups.com
From: On Behalf Of Andy Wokula

> Am 13.02.2012 22:54, schrieb Alexey Muranov:
> > When searching (with "/") and a partial match is highlighted, and the
> > first partial match is a part of the string one is looking for, it
> > would be nice if instead of typing the rest of the search string, one
> > could simply hit the right arrow a number of times to simultaneously
> > extend the highlighted match and complete the search string.
>
> You are looking for CTRL-L
> It's already there :-)

...and how would one find that? ':he ^L' just goes to the :redraw help
and the ':he /' section doesn't appear to talk about 'ctrl-l'.

The help is implemented with tags, and I've often wondered why ':tn'
doesn't do the obvious thing and take you to the next related help
topic. In this case cycling through ':redraw', <search's ctrl-l help>,
<whatever>, etc.

...Stu, vim user for 20 years, but still learning...

Christian Brabandt

unread,
Feb 14, 2012, 9:01:21 AM2/14/12
to vim...@googlegroups.com

If you use
:tag /CTRL-L
you can then use :tn to jump to all the different matchting tags.

regards,
Christian

John Little

unread,
Feb 14, 2012, 7:08:30 PM2/14/12
to vim_dev
On Feb 14, 9:17 pm, Alexey Muranov <alexey.mura...@gmail.com> wrote:

> Thanks a lot, i should have googled better.

IMO searching vim's help directly is better than googling. People
just like you pour over vim's help and suggest changes and cross
references over the years.

:help incsearch was what you needed, and that shows (very
interestingly to me) as well as ctrl-l there's
ctrl-r ctrl-w.

Regards, John

Andy Wokula

unread,
Feb 15, 2012, 6:31:09 AM2/15/12
to vim...@googlegroups.com
Am 14.02.2012 14:53, schrieb MacDonald, Stuart:
> From: On Behalf Of Andy Wokula
>> Am 13.02.2012 22:54, schrieb Alexey Muranov:
>>> When searching (with "/") and a partial match is highlighted, and the
>>> first partial match is a part of the string one is looking for, it
>>> would be nice if instead of typing the rest of the search string, one
>>> could simply hit the right arrow a number of times to simultaneously
>>> extend the highlighted match and complete the search string.
>>
>> You are looking for CTRL-L
>> It's already there :-)
>
> ...and how would one find that? ':he ^L' just goes to the :redraw help
> and the ':he /' section doesn't appear to talk about 'ctrl-l'.

The very first help page
:help
is a must-read. It says, to find a cmdline-specific key, prepend "c_":
:h c_^L
or
:h c_CTRL-L

> The help is implemented with tags, and I've often wondered why ':tn'
> doesn't do the obvious thing and take you to the next related help
> topic. In this case cycling through ':redraw',<search's ctrl-l help>,
> <whatever>, etc.
>
> ...Stu, vim user for 20 years, but still learning...

Maybe because this idea isn't so obvious for other people?
At least there is a todo item (without priority):

:h todo|/^Help
Help:
- When a help item has multiple matches make it possible to use ":tn" to go
to the other matches.

--
Andy

MacDonald, Stuart

unread,
Feb 15, 2012, 9:44:42 AM2/15/12
to vim...@googlegroups.com
From: On Behalf Of Christian Brabandt

> On Tue, February 14, 2012 14:53, MacDonald, Stuart wrote:
> > ...and how would one find that? ':he ^L' just goes to the :redraw help
> > and the ':he /' section doesn't appear to talk about 'ctrl-l'.
> >
> > The help is implemented with tags, and I've often wondered why ':tn'
> > doesn't do the obvious thing and take you to the next related help
> > topic. In this case cycling through ':redraw', <search's ctrl-l help>,
> > <whatever>, etc.
>
> If you use
> :tag /CTRL-L
> you can then use :tn to jump to all the different matchting tags.

Yes, when you have a tags file. That does not work in the help system,
which is what I was asking about. On second thought, I suppose my
actual question is, why doesn't the help contain a pre-built tags
file? On third thought, perhaps because what I'm asking for is more of
an index operation, which is a looser association that a series of
tags is normally.

Also, ':he /^L' gives 'E149: Sorry, no help...'

My question stands, how would a user find out about ctrl-l within the
/ operator? (For the record, this appears to be answered elsethread.)

...Stu

MacDonald, Stuart

unread,
Feb 15, 2012, 9:50:28 AM2/15/12
to vim_dev
From: On Behalf Of John Little

> IMO searching vim's help directly is better than googling. People
> just like you pour over vim's help and suggest changes and cross
> references over the years.
>
> :help incsearch was what you needed, and that shows (very
> interestingly to me) as well as ctrl-l there's
> ctrl-r ctrl-w.

So there's a cross-reference missing between ':he /' and ':he incs'.
How about this update:

While typing the search pattern the current match will be shown if the
'incsearch' option is on. 'incsearch' also includes commands to
auto-complete the search pattern. Remember that you still have to
finish the search command with <CR> to actually position the cursor at
the displayed match. Or use <Esc> to abandon the search.

...Stu

MacDonald, Stuart

unread,
Feb 15, 2012, 10:01:02 AM2/15/12
to vim...@googlegroups.com
From: On Behalf Of Andy Wokula
> The very first help page
> :help
> is a must-read. It says, to find a cmdline-specific key, prepend "c_":
> :h c_^L
> or
> :h c_CTRL-L

Ah, thanks. I haven't read the first page in... decades I guess. Even
so, it probably would not have occurred to me to use _commandline_
help to locate something about _searchmode_ behaviour, even thought
there is a cross-reference in there.

I guess my new method is to try the naive ':he <xyz>' first, then try
each of the c_, i_, etc next. *Then* google.

> > The help is implemented with tags, and I've often wondered why ':tn'
> > doesn't do the obvious thing and take you to the next related help
> > topic. In this case cycling through ':redraw',<search's ctrl-l help>,
> > <whatever>, etc.
>

> Maybe because this idea isn't so obvious for other people?

:-) I guess it's obvious to tags users (programmers, largely).
Although, elsethread I came to the conclusion what I really want is
something more like an index, instead of strictly tags, which implies
a manually-built tags file. :-(

> At least there is a todo item (without priority):
>
> :h todo|/^Help
> Help:
> - When a help item has multiple matches make it possible to use ":tn"
> to go
> to the other matches.

Nifty! I have learned two things about vim today.

...Stu

Christian Brabandt

unread,
Feb 15, 2012, 10:20:23 AM2/15/12
to vim...@googlegroups.com
Hi MacDonald,!

On Mi, 15 Feb 2012, MacDonald, Stuart wrote:

> From: On Behalf Of Christian Brabandt
> > On Tue, February 14, 2012 14:53, MacDonald, Stuart wrote:
> > > ...and how would one find that? ':he ^L' just goes to the :redraw help
> > > and the ':he /' section doesn't appear to talk about 'ctrl-l'.
> > >
> > > The help is implemented with tags, and I've often wondered why ':tn'
> > > doesn't do the obvious thing and take you to the next related help
> > > topic. In this case cycling through ':redraw', <search's ctrl-l help>,
> > > <whatever>, etc.
> >
> > If you use
> > :tag /CTRL-L
> > you can then use :tn to jump to all the different matchting tags.
>
> Yes, when you have a tags file. That does not work in the help system,
> which is what I was asking about. On second thought, I suppose my

You didn't try it, right? Open the help and enter:
:tag /Ctrl-L
The third :tn will bring you to :h c_Ctrl-L

> actual question is, why doesn't the help contain a pre-built tags
> file? On third thought, perhaps because what I'm asking for is more of

There is a pre-built tags file for the help. Its $VIMRUNTIME/doc/tags
and can be updated with :helptags

> an index operation, which is a looser association that a series of
> tags is normally.
>
> Also, ':he /^L' gives 'E149: Sorry, no help...'

Don't use the literal ^L but type CTRL-L

> My question stands, how would a user find out about ctrl-l within the
> / operator? (For the record, this appears to be answered elsethread.)

Usually you prepend a letter plus a low dash for the mode, in which you
are interested, e.g. 'i_', if you need to find out a key-combination in
insert mode (e.g. :h i_CTRL-X_CTRL-F for insert mode completion) or 'c_'
for command mode, as in this case and as Andy already told you. And at
last, you can always :helpgrep for grepping inside the help files for
any search string.

regards,
Christian

MacDonald, Stuart

unread,
Feb 16, 2012, 10:25:55 AM2/16/12
to vim...@googlegroups.com
From: On Behalf Of Christian Brabandt
> On Mi, 15 Feb 2012, MacDonald, Stuart wrote:
> > Yes, when you have a tags file. That does not work in the help system,
> > which is what I was asking about. On second thought, I suppose my
>
> You didn't try it, right? Open the help and enter:

Wrong. I came >< that close to replying to your original suggestion
with the same "didn't try it, right?" but figured I'd rather be sure.
So I tried several combinations, none of which worked...

> :tag /Ctrl-L
> The third :tn will bring you to :h c_Ctrl-L

...except I didn't try the one combination that does work: typing what
you said literally. ':tag /^L' doesn't work for instance. So yes, your
suggestion works but it uses the :tag command in a way I've never used
it before.

> There is a pre-built tags file for the help. Its $VIMRUNTIME/doc/tags
> and can be updated with :helptags

Nifty! Thanks.

> Usually you prepend a letter plus a low dash for the mode, in which you
> are interested, e.g. 'i_', if you need to find out a key-combination in
> insert mode (e.g. :h i_CTRL-X_CTRL-F for insert mode completion) or 'c_'
> for command mode, as in this case and as Andy already told you. And at
> last, you can always :helpgrep for grepping inside the help files for
> any search string.

Also didn't know about :helpgrep. Thanks!

...Stu

Reply all
Reply to author
Forward
0 new messages