Re: Wish list for a more powerful search in Vim

2016-08-26 Fir de Conversatie Yegappan Lakshmanan
Hi,

On Thu, Jul 14, 2016 at 10:54 PM, Yegappan Lakshmanan
 wrote:
> Hi all,
>
> My wish list for extending the Vim search feature:
>
> 1. When searching for a pattern, pressing a key at the search prompt
> should jump to the next or previous match.
> 2. After jumping multiple times from the search prompt, pressing the
> escape key should restore the cursor to the original cursor position
> before the search.
> 3. Pressing backspace at the search prompt to erase a few characters and
> then typing additional characters should start the search from the
> previously matched position and not from the original position.
>

Thanks to Christian for implementing the above features.

>
> 4. As characters are typed at the search prompt, all the matching text
> should be highlighted (multiple matches). This can be turned on/off by
> an option.
>

It will be useful to add the above feature also :-) - Highlighting all the
text matching the search pattern. This may have performance issues
(if there are a large number of matches) and may need some tuning.
So this can be enabled/disabled through an option. The highlighting
for the current match (IncSearch) can be different from the highlighting
used for the other matches.

Regards,
Yegappan

>
> I know there are some Vim plugins that support some of these features.
> But it will be useful to extend the built-in Vim feature to support these
> features.
>
> Thanks,
> Yegappan

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wish list for a more powerful search in Vim

2016-08-25 Fir de Conversatie Yegappan Lakshmanan
Hi Christian,

On Wed, Aug 24, 2016 at 1:48 PM, Christian Brabandt  wrote:
> On Mi, 24 Aug 2016, Christian Brabandt wrote:
>
>> Updated patch attached. This fixes the mentioned problem plus some off
>> by one error and adds some more tests
>
> Sorry, please discard, it was the wrong patch. Correct patch attached to
> this mail.
>

I tested the latest patch. I can confirm that the problems I reported earlier
are all fixed. It will be useful to include this enhancement in the
Vim 8 release.

Thanks,
Yegappan

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wish list for a more powerful search in Vim

2016-08-24 Fir de Conversatie Christian Brabandt
On Mi, 24 Aug 2016, Christian Brabandt wrote:

> Updated patch attached. This fixes the mentioned problem plus some off 
> by one error and adds some more tests

Sorry, please discard, it was the wrong patch. Correct patch attached to 
this mail.

Best,
Christian
-- 
Mann, bin ich belesen, ey.
-- Nina Hagen

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
From 6544323e3400c04986a7538128f6983970191b81 Mon Sep 17 00:00:00 2001
From: Christian Brabandt 
Date: Tue, 26 Jul 2016 11:18:51 +0200
Subject: [PATCH] Make Ctrl-N/P jump to next/previous search match

Currently, you cannot move from one match to the next match
when doing a search '/' or '?'.
This patch adds the functionality to use 'Ctrl-N' to move the
cursor to the next match, if 'insearch' is set. Similarily 'Ctrl-P' will
move to the previous match.

Also c_CTRL-N and c_CTRL-P are already used to move within in history of
search patterns, I have for now made them something different in search
mode, when incsearch is set. This is because c_CTRL-L already does
something useful in search mode and second, because Ctrl-N and
Ctrl-P are already used to select next/previous match in completion mode
so it seems logically to also extend their use in search mode.

Bugfixes: - works correctly with Ctrl-P after ? search
  - after clearing the search command line, starts searching
back at the original position
  - works correctly, when using \? in a forward search / and
then jumping backwards using Ctrl-P
  - obey to 'wrapscan' setting
  - beep, when no further match is found
  - fix cursor moved when backspacing a character and adding
another char
  - when wrapping around and finishing the search using 
make sure, cursor is back at the match
  - Make sure, going backwards skips to the correct match
(Skip SEARCH_COL for going backwards)
  - add test_search.vim for testing
(drop modeline)

Updated enhanced search patch
---
 runtime/doc/cmdline.txt |   9 ++
 src/ex_getln.c  | 160 -
 src/testdir/Make_all.mak|   1 +
 src/testdir/test_search.vim | 242 
 4 files changed, 384 insertions(+), 28 deletions(-)
 create mode 100644 src/testdir/test_search.vim

diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index 8186678..7fe2a34 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -409,11 +409,19 @@ CTRL-D		List names that match the pattern in front of the cursor.
 			*c_CTRL-N*
 CTRL-N		After using 'wildchar' which got multiple matches, go to next
 		match.  Otherwise recall more recent command-line from history.
+		*/_CTRL-N*
+		When 'incsearch' is set, entering a search pattern for "/" or
+		"?" and the current match is displayed then CTRL-N will move
+		to the next match (does not take |search-offset| into account)
 			*c_CTRL-P* *c_*
 CTRL-P		After using 'wildchar' which got multiple matches, go to
 		previous match.  Otherwise recall older command-line from
 		history.   only works with the GUI, on the Amiga and
 		with MS-DOS.
+		*/_CTRL-P*
+		When 'incsearch' is set, entering a search pattern for "/" or
+		"?" and the current match is displayed then CTRL-P will move
+		to the previous match (does not take |search-offset| into account).
 			*c_CTRL-A*
 CTRL-A		All names that match the pattern in front of the cursor are
 		inserted.
@@ -423,6 +431,7 @@ CTRL-L		A match is done on the pattern in front of the cursor.  If
 		If there are multiple matches the longest common part is
 		inserted in place of the pattern.  If the result is shorter
 		than the pattern, no completion is done.
+			*/_CTRL-L*
 		When 'incsearch' is set, entering a search pattern for "/" or
 		"?" and the current match is displayed then CTRL-L will add
 		one character from the end of the current match.  If
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 642e090..819f084 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -137,6 +137,9 @@ _RTLENTRYF
 #endif
 sort_func_compare(const void *s1, const void *s2);
 #endif
+#ifdef FEAT_SEARCH_EXTRA
+static void set_search_match(pos_T *t);
+#endif
 
 /*
  * getcmdline() - accept a command line starting with firstc.
@@ -178,6 +181,9 @@ getcmdline(
 colnr_T	old_curswant;
 colnr_T	old_leftcol;
 linenr_T	old_topline;
+pos_T   

Re: Wish list for a more powerful search in Vim

2016-08-24 Fir de Conversatie Christian Brabandt
On So, 21 Aug 2016, Christian Brabandt wrote:

> On Mo, 08 Aug 2016, Yegappan Lakshmanan wrote:
> 
> > In the above line with the cursor at the beginning of the line,
> > search for "text", press  and then press .
> > The expected behavior is for the cursor to be placed at the
> > first "text". But the cursor is not moved and is still placed
> > at the second "text".
> > 
> > If the pattern appears in a different line, then the problem is
> > not seen. Example:
> > 
> > some text
> > some text
> 
> Thanks for the feedback. Will send an update later this week.

Updated patch attached. This fixes the mentioned problem plus some off 
by one error and adds some more tests

Best,
Christian
-- 
Warum sterben die allermeisten Leute genau drei Tage vor ihrer
Beerdigung, und warum tut niemand etwas gegen diese Beerdigungen?

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
From f7e06483300fcc632414ad49afb30f4459336d78 Mon Sep 17 00:00:00 2001
From: Christian Brabandt 
Date: Tue, 26 Jul 2016 11:18:51 +0200
Subject: [PATCH] Make Ctrl-N/P jump to next/previous search match

Currently, you cannot move from one match to the next match
when doing a search '/' or '?'.
This patch adds the functionality to use 'Ctrl-N' to move the
cursor to the next match, if 'insearch' is set. Similarily 'Ctrl-P' will
move to the previous match.

Also c_CTRL-N and c_CTRL-P are already used to move within in history of
search patterns, I have for now made them something different in search
mode, when incsearch is set. This is because c_CTRL-L already does
something useful in search mode and second, because Ctrl-N and
Ctrl-P are already used to select next/previous match in completion mode
so it seems logically to also extend their use in search mode.

Bugfixes: - works correctly with Ctrl-P after ? search
  - after clearing the search command line, starts searching
back at the original position
  - works correctly, when using \? in a forward search / and
then jumping backwards using Ctrl-P
  - obey to 'wrapscan' setting
  - beep, when no further match is found
  - fix cursor moved when backspacing a character and adding
another char
  - when wrapping around and finishing the search using 
make sure, cursor is back at the match
  - add test_search.vim for testing

Updated enhanced search patch
---
 runtime/doc/cmdline.txt |   9 ++
 src/ex_getln.c  | 163 +---
 src/testdir/Make_all.mak|   1 +
 src/testdir/test_search.vim | 198 
 4 files changed, 343 insertions(+), 28 deletions(-)
 create mode 100644 src/testdir/test_search.vim

diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index 8186678..7fe2a34 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -409,11 +409,19 @@ CTRL-D		List names that match the pattern in front of the cursor.
 			*c_CTRL-N*
 CTRL-N		After using 'wildchar' which got multiple matches, go to next
 		match.  Otherwise recall more recent command-line from history.
+		*/_CTRL-N*
+		When 'incsearch' is set, entering a search pattern for "/" or
+		"?" and the current match is displayed then CTRL-N will move
+		to the next match (does not take |search-offset| into account)
 			*c_CTRL-P* *c_*
 CTRL-P		After using 'wildchar' which got multiple matches, go to
 		previous match.  Otherwise recall older command-line from
 		history.   only works with the GUI, on the Amiga and
 		with MS-DOS.
+		*/_CTRL-P*
+		When 'incsearch' is set, entering a search pattern for "/" or
+		"?" and the current match is displayed then CTRL-P will move
+		to the previous match (does not take |search-offset| into account).
 			*c_CTRL-A*
 CTRL-A		All names that match the pattern in front of the cursor are
 		inserted.
@@ -423,6 +431,7 @@ CTRL-L		A match is done on the pattern in front of the cursor.  If
 		If there are multiple matches the longest common part is
 		inserted in place of the pattern.  If the result is shorter
 		than the pattern, no completion is done.
+			*/_CTRL-L*
 		When 'incsearch' is set, entering a search pattern for "/" or
 		"?" and the current match is displayed then CTRL-L will add
 		one character from the end of the current match.  If
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 642e090..7ce04b4 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -137,6 

Re: Wish list for a more powerful search in Vim

2016-08-21 Fir de Conversatie Christian Brabandt
Hi Yegappan!

On Mo, 08 Aug 2016, Yegappan Lakshmanan wrote:

> In the above line with the cursor at the beginning of the line,
> search for "text", press  and then press .
> The expected behavior is for the cursor to be placed at the
> first "text". But the cursor is not moved and is still placed
> at the second "text".
> 
> If the pattern appears in a different line, then the problem is
> not seen. Example:
> 
> some text
> some text

Thanks for the feedback. Will send an update later this week.

Best,
Christian
-- 
Wie wechselt ein ein Windowsprogrammierer eine Glühbirne?
Gar nicht, ist ein Hardwareproblem!

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wish list for a more powerful search in Vim

2016-08-08 Fir de Conversatie Yegappan Lakshmanan
Hi Christian,

On Wed, Aug 3, 2016 at 3:58 PM, Yegappan Lakshmanan  wrote:
>>> >> >
>>> >> >> I think it should.  Most users will have 'wrapscan' on, since it is 
>>> >> >> the
>>> >> >> default.  If someone switches it off he must have a reason for it.
>>> >> >
>>> >> > okay, fixed with the latest version
>>> >> >
>>> >>
>>> >> I tested the latest patch and the confirmed that the problems I reported 
>>> >> earlier
>>> >> are fixed. I saw some new issues. Take the following text:
>>> >>
>>> >>   1
>>> >>   2 these
>>> >>   3 the
>>> >>   4 their
>>> >>   5 there
>>> >>   6 their
>>> >>   7 the
>>> >>   8 them
>>> >>   9 these
>>> >>
>>> >> The cursor is in line 1 and I have 'nowrapscan' set. I search for "the" 
>>> >> and
>>> >> press CTRL-N 7 times and "the" in "these" is highlighted. Now I press
>>> >> CTRL-L to copy "s" and then erase it. Now if I press CTRL-P, I expect
>>> >> that the cursor will move to line 8. Instead the cursor moves to line 7.
>>> >>
>>> >> Another problem: Place the cursor in line 1. Enter "/thes" and then press
>>> >> CTRL-N. The "thes" in line 9 is highlighted. Now if you press backspace,
>>> >> the cursor jumps back to line 3. I expected that the cursor will remain
>>> >> in line 9.
>>> >
>>> > Thanks, will look at these and add some tests.
>>> >
>>> >> I think, the CTRL-N and CTRL-P should respect the search direction.
>>> >> For example, if I search a pattern using "?text", pressing CTRL-N
>>> >> should search backwards. Currently CTRL-N always searches
>>> >> forward (irrespective of the search direction). Note that this is
>>> >> different from how "n" and "N" work.
>>> >
>>> > Please don't make me do this. Currently the inconsistent search
>>> > direction is one of my biggest annoyances of Vim. I really really really
>>> > hate it, that I can't rely on the fact that N searches backwards and n
>>> > forward.
>>> >
>>>
>>> I don't have any preference between the two options. I was just pointing
>>> out the deviation from the behavior of 'n' and 'N' commands.
>>
>> I attach an updated patch, which fixes all issues mentioned so far.
>> Additionally I added a test for this.
>>
>
> I can confirm that this patch fixes all the issues reported so far.
> I played around with CTRL-N and CTRL-P at the search prompt
> for some time and didn't find any issues.
>

I found a problem with searching for a pattern in a single line if
the pattern appears more than once in the line. Example:

some text some text

In the above line with the cursor at the beginning of the line,
search for "text", press  and then press .
The expected behavior is for the cursor to be placed at the
first "text". But the cursor is not moved and is still placed
at the second "text".

If the pattern appears in a different line, then the problem is
not seen. Example:

some text
some text

- Yegappan

>
>>
>> I will be away the next 2-3 weeks, so won't have time to work on this
>> further. However, I'd appreciate feedback and will work further on it
>> after I return, if there are more issues.
>>
>> Oh and before I forget to mention it. I made Ctrl-N always go further
>> down and Ctrl-P always go further up and I don't intend to change that.
>>

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wish list for a more powerful search in Vim

2016-08-03 Fir de Conversatie Kent Sibilev
On Wednesday, August 3, 2016 at 3:54:18 PM UTC-4, Christian Brabandt wrote:

> I attach an updated patch, which fixes all issues mentioned so far.
> Additionally I added a test for this.
> 
> I will be away the next 2-3 weeks, so won't have time to work on this 
> further. However, I'd appreciate feedback and will work further on it
> after I return, if there are more issues.
> 
> Oh and before I forget to mention it. I made Ctrl-N always go further 
> down and Ctrl-P always go further up and I don't intend to change that.
> 
> Best,
> Christian

I really like this patch. Thanks for working on it.

Regards,
Kent.

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wish list for a more powerful search in Vim

2016-08-03 Fir de Conversatie Yegappan Lakshmanan
Hi Christian,

On Wed, Aug 3, 2016 at 12:54 PM, Christian Brabandt  wrote:
>
> On Fr, 29 Jul 2016, Yegappan Lakshmanan wrote:
>
>> On Fri, Jul 29, 2016 at 11:03 AM, Christian Brabandt  
>> wrote:
>> >> On Thu, Jul 28, 2016 at 11:16 PM, Christian Brabandt  
>> >> wrote:
>> >> > On Do, 28 Jul 2016, Bram Moolenaar wrote:
>> >> >
>> >> >> I think it should.  Most users will have 'wrapscan' on, since it is the
>> >> >> default.  If someone switches it off he must have a reason for it.
>> >> >
>> >> > okay, fixed with the latest version
>> >> >
>> >>
>> >> I tested the latest patch and the confirmed that the problems I reported 
>> >> earlier
>> >> are fixed. I saw some new issues. Take the following text:
>> >>
>> >>   1
>> >>   2 these
>> >>   3 the
>> >>   4 their
>> >>   5 there
>> >>   6 their
>> >>   7 the
>> >>   8 them
>> >>   9 these
>> >>
>> >> The cursor is in line 1 and I have 'nowrapscan' set. I search for "the" 
>> >> and
>> >> press CTRL-N 7 times and "the" in "these" is highlighted. Now I press
>> >> CTRL-L to copy "s" and then erase it. Now if I press CTRL-P, I expect
>> >> that the cursor will move to line 8. Instead the cursor moves to line 7.
>> >>
>> >> Another problem: Place the cursor in line 1. Enter "/thes" and then press
>> >> CTRL-N. The "thes" in line 9 is highlighted. Now if you press backspace,
>> >> the cursor jumps back to line 3. I expected that the cursor will remain
>> >> in line 9.
>> >
>> > Thanks, will look at these and add some tests.
>> >
>> >> I think, the CTRL-N and CTRL-P should respect the search direction.
>> >> For example, if I search a pattern using "?text", pressing CTRL-N
>> >> should search backwards. Currently CTRL-N always searches
>> >> forward (irrespective of the search direction). Note that this is
>> >> different from how "n" and "N" work.
>> >
>> > Please don't make me do this. Currently the inconsistent search
>> > direction is one of my biggest annoyances of Vim. I really really really
>> > hate it, that I can't rely on the fact that N searches backwards and n
>> > forward.
>> >
>>
>> I don't have any preference between the two options. I was just pointing
>> out the deviation from the behavior of 'n' and 'N' commands.
>
> I attach an updated patch, which fixes all issues mentioned so far.
> Additionally I added a test for this.
>

I can confirm that this patch fixes all the issues reported so far.
I played around with CTRL-N and CTRL-P at the search prompt
for some time and didn't find any issues.

Thanks for working on this.

Regards,
Yegappan

>
> I will be away the next 2-3 weeks, so won't have time to work on this
> further. However, I'd appreciate feedback and will work further on it
> after I return, if there are more issues.
>
> Oh and before I forget to mention it. I made Ctrl-N always go further
> down and Ctrl-P always go further up and I don't intend to change that.
>

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wish list for a more powerful search in Vim

2016-08-03 Fir de Conversatie Christian Brabandt

On Fr, 29 Jul 2016, Yegappan Lakshmanan wrote:

> On Fri, Jul 29, 2016 at 11:03 AM, Christian Brabandt  
> wrote:
> >> On Thu, Jul 28, 2016 at 11:16 PM, Christian Brabandt  
> >> wrote:
> >> > On Do, 28 Jul 2016, Bram Moolenaar wrote:
> >> >
> >> >> I think it should.  Most users will have 'wrapscan' on, since it is the
> >> >> default.  If someone switches it off he must have a reason for it.
> >> >
> >> > okay, fixed with the latest version
> >> >
> >>
> >> I tested the latest patch and the confirmed that the problems I reported 
> >> earlier
> >> are fixed. I saw some new issues. Take the following text:
> >>
> >>   1
> >>   2 these
> >>   3 the
> >>   4 their
> >>   5 there
> >>   6 their
> >>   7 the
> >>   8 them
> >>   9 these
> >>
> >> The cursor is in line 1 and I have 'nowrapscan' set. I search for "the" and
> >> press CTRL-N 7 times and "the" in "these" is highlighted. Now I press
> >> CTRL-L to copy "s" and then erase it. Now if I press CTRL-P, I expect
> >> that the cursor will move to line 8. Instead the cursor moves to line 7.
> >>
> >> Another problem: Place the cursor in line 1. Enter "/thes" and then press
> >> CTRL-N. The "thes" in line 9 is highlighted. Now if you press backspace,
> >> the cursor jumps back to line 3. I expected that the cursor will remain
> >> in line 9.
> >
> > Thanks, will look at these and add some tests.
> >
> >> I think, the CTRL-N and CTRL-P should respect the search direction.
> >> For example, if I search a pattern using "?text", pressing CTRL-N
> >> should search backwards. Currently CTRL-N always searches
> >> forward (irrespective of the search direction). Note that this is
> >> different from how "n" and "N" work.
> >
> > Please don't make me do this. Currently the inconsistent search
> > direction is one of my biggest annoyances of Vim. I really really really
> > hate it, that I can't rely on the fact that N searches backwards and n
> > forward.
> >
> 
> I don't have any preference between the two options. I was just pointing
> out the deviation from the behavior of 'n' and 'N' commands.

I attach an updated patch, which fixes all issues mentioned so far.
Additionally I added a test for this.

I will be away the next 2-3 weeks, so won't have time to work on this 
further. However, I'd appreciate feedback and will work further on it
after I return, if there are more issues.

Oh and before I forget to mention it. I made Ctrl-N always go further 
down and Ctrl-P always go further up and I don't intend to change that.

Best,
Christian

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
From f7e06483300fcc632414ad49afb30f4459336d78 Mon Sep 17 00:00:00 2001
From: Christian Brabandt 
Date: Tue, 26 Jul 2016 11:18:51 +0200
Subject: [PATCH] Make Ctrl-N/P jump to next/previous search match

Currently, you cannot move from one match to the next match
when doing a search '/' or '?'.
This patch adds the functionality to use 'Ctrl-N' to move the
cursor to the next match, if 'insearch' is set. Similarily 'Ctrl-P' will
move to the previous match.

Also c_CTRL-N and c_CTRL-P are already used to move within in history of
search patterns, I have for now made them something different in search
mode, when incsearch is set. This is because c_CTRL-L already does
something useful in search mode and second, because Ctrl-N and
Ctrl-P are already used to select next/previous match in completion mode
so it seems logically to also extend their use in search mode.

Bugfixes: - works correctly with Ctrl-P after ? search
  - after clearing the search command line, starts searching
back at the original position
  - works correctly, when using \? in a forward search / and
then jumping backwards using Ctrl-P
  - obey to 'wrapscan' setting
  - beep, when no further match is found
  - fix cursor moved when backspacing a character and adding
another char
  - when wrapping around and finishing the search using 
make sure, cursor is back at the match
  - add test_search.vim for testing

Updated enhanced search patch
---
 runtime/doc/cmdline.txt |   9 ++
 src/ex_getln.c  | 163 +---
 src/testdir/Make_all.mak|   1 +
 src/testdir/test_search.vim | 198 
 4 files changed, 343 insertions(+), 28 deletions(-)
 create mode 100644 src/testdir/test_search.vim

diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index 

Re: Wish list for a more powerful search in Vim

2016-07-29 Fir de Conversatie Yegappan Lakshmanan
Hi Christian,

On Fri, Jul 29, 2016 at 11:03 AM, Christian Brabandt  wrote:
>>
>> On Thu, Jul 28, 2016 at 11:16 PM, Christian Brabandt  
>> wrote:
>> > On Do, 28 Jul 2016, Bram Moolenaar wrote:
>> >
>> >> I think it should.  Most users will have 'wrapscan' on, since it is the
>> >> default.  If someone switches it off he must have a reason for it.
>> >
>> > okay, fixed with the latest version
>> >
>>
>> I tested the latest patch and the confirmed that the problems I reported 
>> earlier
>> are fixed. I saw some new issues. Take the following text:
>>
>>   1
>>   2 these
>>   3 the
>>   4 their
>>   5 there
>>   6 their
>>   7 the
>>   8 them
>>   9 these
>>
>> The cursor is in line 1 and I have 'nowrapscan' set. I search for "the" and
>> press CTRL-N 7 times and "the" in "these" is highlighted. Now I press
>> CTRL-L to copy "s" and then erase it. Now if I press CTRL-P, I expect
>> that the cursor will move to line 8. Instead the cursor moves to line 7.
>>
>> Another problem: Place the cursor in line 1. Enter "/thes" and then press
>> CTRL-N. The "thes" in line 9 is highlighted. Now if you press backspace,
>> the cursor jumps back to line 3. I expected that the cursor will remain
>> in line 9.
>
> Thanks, will look at these and add some tests.
>
>> I think, the CTRL-N and CTRL-P should respect the search direction.
>> For example, if I search a pattern using "?text", pressing CTRL-N
>> should search backwards. Currently CTRL-N always searches
>> forward (irrespective of the search direction). Note that this is
>> different from how "n" and "N" work.
>
> Please don't make me do this. Currently the inconsistent search
> direction is one of my biggest annoyances of Vim. I really really really
> hate it, that I can't rely on the fact that N searches backwards and n
> forward.
>

I don't have any preference between the two options. I was just pointing
out the deviation from the behavior of 'n' and 'N' commands.

Regards,
Yegappan

>
> (I even made a patch, to make this configurable
> https://github.com/chrisbra/vim-mq-patches/blob/master/cpo-N
> and this is one of the reasons, I made gn always search forward).
>
>> A typo: The help text in cmdline.txt for CTRL-P refers to CTRL-N.
>>
>>the current match is displayed then CTRL-N will move
>>to the previous match
>
> Will fix, thanks.
>

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wish list for a more powerful search in Vim

2016-07-29 Fir de Conversatie Charles E Campbell
Christian Brabandt wrote:
> Hi Yegappan!
>
> On Fr, 29 Jul 2016, Yegappan Lakshmanan wrote:
>
>> Hi Christian,
>>
>> On Thu, Jul 28, 2016 at 11:16 PM, Christian Brabandt  
>> wrote:
>>> On Do, 28 Jul 2016, Bram Moolenaar wrote:
>>>
 I think it should.  Most users will have 'wrapscan' on, since it is the
 default.  If someone switches it off he must have a reason for it.
>>> okay, fixed with the latest version
>>>
>> I tested the latest patch and the confirmed that the problems I reported 
>> earlier
>> are fixed. I saw some new issues. Take the following text:
>>
>>   1
>>   2 these
>>   3 the
>>   4 their
>>   5 there
>>   6 their
>>   7 the
>>   8 them
>>   9 these
>>
>> The cursor is in line 1 and I have 'nowrapscan' set. I search for "the" and
>> press CTRL-N 7 times and "the" in "these" is highlighted. Now I press
>> CTRL-L to copy "s" and then erase it. Now if I press CTRL-P, I expect
>> that the cursor will move to line 8. Instead the cursor moves to line 7.
>>
>> Another problem: Place the cursor in line 1. Enter "/thes" and then press
>> CTRL-N. The "thes" in line 9 is highlighted. Now if you press backspace,
>> the cursor jumps back to line 3. I expected that the cursor will remain
>> in line 9.
> Thanks, will look at these and add some tests.
>
>> I think, the CTRL-N and CTRL-P should respect the search direction.
>> For example, if I search a pattern using "?text", pressing CTRL-N
>> should search backwards. Currently CTRL-N always searches
>> forward (irrespective of the search direction). Note that this is
>> different from how "n" and "N" work.
> Please don't make me do this. Currently the inconsistent search 
> direction is one of my biggest annoyances of Vim. I really really really 
> hate it, that I can't rely on the fact that N searches backwards and n 
> forward.
>
> (I even made a patch, to make this configurable 
> https://github.com/chrisbra/vim-mq-patches/blob/master/cpo-N
> and this is one of the reasons, I made gn always search forward).
>
That's because, Christian, you keep your eyes on the front of your
head.  You need to move them to back of your head occasionally, and that
way you'll get used to the idea.
:)

Regards,
Chip Campbell

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wish list for a more powerful search in Vim

2016-07-29 Fir de Conversatie Christian Brabandt
Hi Yegappan!

On Fr, 29 Jul 2016, Yegappan Lakshmanan wrote:

> Hi Christian,
> 
> On Thu, Jul 28, 2016 at 11:16 PM, Christian Brabandt  
> wrote:
> > On Do, 28 Jul 2016, Bram Moolenaar wrote:
> >
> >> I think it should.  Most users will have 'wrapscan' on, since it is the
> >> default.  If someone switches it off he must have a reason for it.
> >
> > okay, fixed with the latest version
> >
> 
> I tested the latest patch and the confirmed that the problems I reported 
> earlier
> are fixed. I saw some new issues. Take the following text:
> 
>   1
>   2 these
>   3 the
>   4 their
>   5 there
>   6 their
>   7 the
>   8 them
>   9 these
> 
> The cursor is in line 1 and I have 'nowrapscan' set. I search for "the" and
> press CTRL-N 7 times and "the" in "these" is highlighted. Now I press
> CTRL-L to copy "s" and then erase it. Now if I press CTRL-P, I expect
> that the cursor will move to line 8. Instead the cursor moves to line 7.
> 
> Another problem: Place the cursor in line 1. Enter "/thes" and then press
> CTRL-N. The "thes" in line 9 is highlighted. Now if you press backspace,
> the cursor jumps back to line 3. I expected that the cursor will remain
> in line 9.

Thanks, will look at these and add some tests.

> I think, the CTRL-N and CTRL-P should respect the search direction.
> For example, if I search a pattern using "?text", pressing CTRL-N
> should search backwards. Currently CTRL-N always searches
> forward (irrespective of the search direction). Note that this is
> different from how "n" and "N" work.

Please don't make me do this. Currently the inconsistent search 
direction is one of my biggest annoyances of Vim. I really really really 
hate it, that I can't rely on the fact that N searches backwards and n 
forward.

(I even made a patch, to make this configurable 
https://github.com/chrisbra/vim-mq-patches/blob/master/cpo-N
and this is one of the reasons, I made gn always search forward).

> A typo: The help text in cmdline.txt for CTRL-P refers to CTRL-N.
> 
>the current match is displayed then CTRL-N will move
>to the previous match

Will fix, thanks.

Mit freundlichen Grüßen
Christian
-- 
Phantasie ist etwas, das sich viele gar nicht vorstellen können.
-- Helmut Qualtinger

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wish list for a more powerful search in Vim

2016-07-29 Fir de Conversatie Yegappan Lakshmanan
Hi Christian,

On Thu, Jul 28, 2016 at 11:16 PM, Christian Brabandt  wrote:
> On Do, 28 Jul 2016, Bram Moolenaar wrote:
>
>> I think it should.  Most users will have 'wrapscan' on, since it is the
>> default.  If someone switches it off he must have a reason for it.
>
> okay, fixed with the latest version
>

I tested the latest patch and the confirmed that the problems I reported earlier
are fixed. I saw some new issues. Take the following text:

  1
  2 these
  3 the
  4 their
  5 there
  6 their
  7 the
  8 them
  9 these

The cursor is in line 1 and I have 'nowrapscan' set. I search for "the" and
press CTRL-N 7 times and "the" in "these" is highlighted. Now I press
CTRL-L to copy "s" and then erase it. Now if I press CTRL-P, I expect
that the cursor will move to line 8. Instead the cursor moves to line 7.

Another problem: Place the cursor in line 1. Enter "/thes" and then press
CTRL-N. The "thes" in line 9 is highlighted. Now if you press backspace,
the cursor jumps back to line 3. I expected that the cursor will remain
in line 9.

I think, the CTRL-N and CTRL-P should respect the search direction.
For example, if I search a pattern using "?text", pressing CTRL-N
should search backwards. Currently CTRL-N always searches
forward (irrespective of the search direction). Note that this is
different from how "n" and "N" work.

A typo: The help text in cmdline.txt for CTRL-P refers to CTRL-N.

   the current match is displayed then CTRL-N will move
   to the previous match

- Yegappan

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wish list for a more powerful search in Vim

2016-07-29 Fir de Conversatie Christian Brabandt
On Do, 28 Jul 2016, Bram Moolenaar wrote:

> I think it should.  Most users will have 'wrapscan' on, since it is the
> default.  If someone switches it off he must have a reason for it.

okay, fixed with the latest version

Best,
Christian
-- 
Das Gedruckte übt einen mächtigen Druck aus, der besondere Glaube 
ans Gedruckte ist einer der mächtigsten Aberglauben.
-- Ludwig Marcuse (Argumente und Rezepte)

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
From 74680771664103cf043a11cf96e47eb9693b9a51 Mon Sep 17 00:00:00 2001
From: Christian Brabandt 
Date: Tue, 26 Jul 2016 11:18:51 +0200
Subject: [PATCH] Make Ctrl-N/P jump to next/previous search match

Currently, you cannot move from one match to the next match
when doing a search '/' or '?'.
This patch adds the functionality to use 'Ctrl-N' to move the
cursor to the next match, if 'insearch' is set. Similarily 'Ctrl-P' will
move to the previous match.

Also c_CTRL-N and c_CTRL-P are already used to move within in history of
search patterns, I have for now made them something different in search
mode, when incsearch is set. This is because c_CTRL-L already does
something useful in search mode and second, because Ctrl-N and
Ctrl-P are already used to select next/previous match in completion mode
so it seems logically to also extend their use in search mode.

Bugfixes: - works correctly with Ctrl-P after ? search
  - after clearing the search command line, starts searching
	back at the original position
	  - works correctly, when using \? in a forward search / and
	then jumping backwards using Ctrl-P
	  - obey to 'wrapscan' setting
	  - beep, when no further match is found
---
 runtime/doc/cmdline.txt |  9 +
 src/ex_getln.c  | 96 +++--
 2 files changed, 103 insertions(+), 2 deletions(-)

diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index 8186678..83bec9e 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -409,11 +409,19 @@ CTRL-D		List names that match the pattern in front of the cursor.
 			*c_CTRL-N*
 CTRL-N		After using 'wildchar' which got multiple matches, go to next
 		match.  Otherwise recall more recent command-line from history.
+		*/_CTRL-N*
+		When 'incsearch' is set, entering a search pattern for "/" or
+		"?" and the current match is displayed then CTRL-N will move
+		to the next match (does not take |search-offset| into account)
 			*c_CTRL-P* *c_*
 CTRL-P		After using 'wildchar' which got multiple matches, go to
 		previous match.  Otherwise recall older command-line from
 		history.   only works with the GUI, on the Amiga and
 		with MS-DOS.
+		*/_CTRL-P*
+		When 'incsearch' is set, entering a search pattern for "/" or
+		"?" and the current match is displayed then CTRL-N will move
+		to the previous match (does not take |search-offset| into account).
 			*c_CTRL-A*
 CTRL-A		All names that match the pattern in front of the cursor are
 		inserted.
@@ -423,6 +431,7 @@ CTRL-L		A match is done on the pattern in front of the cursor.  If
 		If there are multiple matches the longest common part is
 		inserted in place of the pattern.  If the result is shorter
 		than the pattern, no completion is done.
+			*/_CTRL-L*
 		When 'incsearch' is set, entering a search pattern for "/" or
 		"?" and the current match is displayed then CTRL-L will add
 		one character from the end of the current match.  If
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 642e090..7862b0e 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -178,6 +178,8 @@ getcmdline(
 colnr_T	old_curswant;
 colnr_T	old_leftcol;
 linenr_T	old_topline;
+int		did_incs_move = FALSE;
+pos_T   cursor_start;
 # ifdef FEAT_DIFF
 int		old_topfill;
 # endif
@@ -224,6 +226,7 @@ getcmdline(
 ccline.overstrike = FALSE;		/* always start in insert mode */
 #ifdef FEAT_SEARCH_EXTRA
 old_cursor = curwin->w_cursor;	/* needs to be restored later */
+cursor_start = old_cursor;
 old_curswant = curwin->w_curswant;
 old_leftcol = curwin->w_leftcol;
 old_topline = curwin->w_topline;
@@ -996,6 +999,10 @@ getcmdline(
 
 		/* Truncate at the end, required for multi-byte chars. */
 		ccline.cmdbuff[ccline.cmdlen] = NUL;
+#ifdef FEAT_SEARCH_EXTRA
+		if (ccline.cmdlen == 0)
+			old_cursor = cursor_start;
+#endif
 		redrawcmd();
 		}
 		else if (ccline.cmdlen == 0 && c != Ctrl_W
@@ -1021,6 

Re: Wish list for a more powerful search in Vim

2016-07-28 Fir de Conversatie Bram Moolenaar

Christian Brabandt wrote:

> Hi Yegappan,
> attached is an updated patch, that fixes a couple of bugs. Especially, 
> using a pattern that uses the \? atom and then jumping backwards did not 
> work. This is fixed now.
> 
> On Di, 26 Jul 2016, Yegappan Lakshmanan wrote:
> 
> > 1. When pressing CTRL-N or CTRL-P to jump to the next/previous match,
> >the 'nowrapscan' setting is ignored and the search wraps around
> >the file.
> 
> not fixed, because I am not sure it should really consider the wrapscan 
> setting.

I think it should.  Most users will have 'wrapscan' on, since it is the
default.  If someone switches it off he must have a reason for it.

> > 2. After pressing CTRL-N couple of times, erasing the entire search pattern
> >and typing a new pattern doesn't search from the original cursor
> >position. Instead the search starts from the last matched position.
> 
> should be fixed now.
> 
> > 3. Searching for a pattern, pressing CTRL-N (which doesn't find a
> >next match) and then pressing CTRL-L to copy the next character
> >from under the cursor doesn't work and also the search highlighting
> >is removed.
> 
> I don't understand that problem or I cannot reproduce it. Can you give 
> me a reproducible example, together with the buffer contents?

-- 
You can be stopped by the police for biking over 65 miles per hour.
You are not allowed to walk across a street on your hands.
[real standing laws in Connecticut, United States of America]

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wish list for a more powerful search in Vim

2016-07-28 Fir de Conversatie Christian Brabandt
Hi Yegappan,
attached is an updated patch, that fixes a couple of bugs. Especially, 
using a pattern that uses the \? atom and then jumping backwards did not 
work. This is fixed now.

On Di, 26 Jul 2016, Yegappan Lakshmanan wrote:

> 1. When pressing CTRL-N or CTRL-P to jump to the next/previous match,
>the 'nowrapscan' setting is ignored and the search wraps around
>the file.

not fixed, because I am not sure it should really consider the wrapscan 
setting.

> 2. After pressing CTRL-N couple of times, erasing the entire search pattern
>and typing a new pattern doesn't search from the original cursor
>position. Instead the search starts from the last matched position.

should be fixed now.

> 3. Searching for a pattern, pressing CTRL-N (which doesn't find a
>next match) and then pressing CTRL-L to copy the next character
>from under the cursor doesn't work and also the search highlighting
>is removed.

I don't understand that problem or I cannot reproduce it. Can you give 
me a reproducible example, together with the buffer contents?

Best,
Christian
-- 
Wir sind die Menschen, vor denen uns unsere Eltern gewarnt haben.

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
From 1bacaae1141826ebb6e2611f423aedee2854febc Mon Sep 17 00:00:00 2001
From: Christian Brabandt 
Date: Tue, 26 Jul 2016 11:18:51 +0200
Subject: [PATCH] Make Ctrl-N/P jump to next/previous search match

Currently, you cannot move from one match to the next match
when doing a search '/' or '?'.
This patch adds the functionality to use 'Ctrl-N' to move the
cursor to the next match, if 'insearch' is set. Similarily 'Ctrl-P' will
move to the previous match.

Also c_CTRL-N and c_CTRL-P are already used to move within in history of
search patterns, I have for now made them something different in search
mode, when incsearch is set. This is because c_CTRL-L already does
something useful in search mode and second, because Ctrl-N and
Ctrl-P are already used to select next/previous match in completion mode
so it seems logically to also extend their use in search mode.

Bugfixes: - works correctly with Ctrl-P after ? search
  - after clearing the search command line, starts searching
	back at the original position
	  - works correctly, when using \? in a forward search / and
	then jumping backwards using Ctrl-P
---
 runtime/doc/cmdline.txt |  9 +
 src/ex_getln.c  | 97 -
 2 files changed, 104 insertions(+), 2 deletions(-)

diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index 8186678..83bec9e 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -409,11 +409,19 @@ CTRL-D		List names that match the pattern in front of the cursor.
 			*c_CTRL-N*
 CTRL-N		After using 'wildchar' which got multiple matches, go to next
 		match.  Otherwise recall more recent command-line from history.
+		*/_CTRL-N*
+		When 'incsearch' is set, entering a search pattern for "/" or
+		"?" and the current match is displayed then CTRL-N will move
+		to the next match (does not take |search-offset| into account)
 			*c_CTRL-P* *c_*
 CTRL-P		After using 'wildchar' which got multiple matches, go to
 		previous match.  Otherwise recall older command-line from
 		history.   only works with the GUI, on the Amiga and
 		with MS-DOS.
+		*/_CTRL-P*
+		When 'incsearch' is set, entering a search pattern for "/" or
+		"?" and the current match is displayed then CTRL-N will move
+		to the previous match (does not take |search-offset| into account).
 			*c_CTRL-A*
 CTRL-A		All names that match the pattern in front of the cursor are
 		inserted.
@@ -423,6 +431,7 @@ CTRL-L		A match is done on the pattern in front of the cursor.  If
 		If there are multiple matches the longest common part is
 		inserted in place of the pattern.  If the result is shorter
 		than the pattern, no completion is done.
+			*/_CTRL-L*
 		When 'incsearch' is set, entering a search pattern for "/" or
 		"?" and the current match is displayed then CTRL-L will add
 		one character from the end of the current match.  If
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 642e090..1c1e421 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -178,6 +178,8 @@ getcmdline(
 colnr_T	old_curswant;
 colnr_T	old_leftcol;
 linenr_T	old_topline;
+int		did_incs_move = FALSE;
+pos_T   cursor_start;
 # ifdef FEAT_DIFF
 int		old_topfill;
 # endif
@@ 

Re: Wish list for a more powerful search in Vim

2016-07-27 Fir de Conversatie Bram Moolenaar

Christian Brabandt wrote:

> >> On Do, 14 Jul 2016, Yegappan Lakshmanan wrote:
> >> 
> >> > Hi all,
> >> >
> >> > My wish list for extending the Vim search feature:
> >> >
> >> > 1. When searching for a pattern, pressing a key at the search prompt
> >> > should jump to the next or previous match.
> >> > 2. After jumping multiple times from the search prompt, pressing the
> >> > escape key should restore the cursor to the original cursor position
> >> > before the search.
> >> > 3. Pressing backspace at the search prompt to erase a few characters and
> >> > then typing additional characters should start the search from the
> >> > previously matched position and not from the original position.
> >> > 4. As characters are typed at the search prompt, all the matching text
> >> > should be highlighted (multiple matches). This can be turned on/off 
> >> > by
> >> > an option.
> >> >
> >> > I know there are some Vim plugins that support some of these features.
> >> > But it will be useful to extend the built-in Vim feature to support these
> >> > features.
> >> 
> >> Here is an experimental patch, that does this using Ctrl-N Ctrl-P in
> >> search mode, when 'incsearch' is set. I am not super happy, about
> >> depending on 'incsearch', but on the other hand, Ctrl-L already only
> >> works when 'incsearch' is set. Also I am open to suggestions for
> >> alternative keys, although I must admit, Ctrl-N/Ctrl-P seem like 
> >> logical
> >> choices.
> >> 
> >> It doesn't do everything you want, but it seems to work well for me. I
> >> made it so, that pressing enter will remain at the current selected
> >> match, which seems obvious and so I did not need to introduce a new 
> >> key
> >> function. Pressing ESC however will return the cursor to the position
> >> where you started with the search.
> >> 
> >> This was just written very fast, I am pretty sure, there are some bugs
> >> lying around and also tests are missing. But if this turns out to be
> >> useful, I'll work more on it (and add a test of course).
> >> 
> >> Comments welcome,
> > 
> > This smells like an interactive search dialog.  Does this combine with
> > the search count?  So when pressing CTRL-N it goes from "match 2 of 23"
> > to "match 3 of 23"?  And when typing a character it goes to "match 1 of
> > 8"?  (I would think the match index is counting from the original start
> > position).
> 
> You mean the search_stat patch from last week? No, I haven't looked,
> how well those two features would work together.
> 
> Would it make sense to submit it as one single patch, adding several
> features at once?

Doesn't matter, just seems that they should well work together.  But if
one needs more time we could include the other first.

-- 
BEDEVERE: Look!  It's the old man from scene 24 - what's he Doing here?
ARTHUR:   He is the keeper of the Bridge.  He asks each traveler five
  questions ...
GALAHAD:  Three questions.
 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wish list for a more powerful search in Vim

2016-07-27 Fir de Conversatie Christian Brabandt

Am 2016-07-26 23:07, schrieb Bram Moolenaar:

Christian Brabandt wrote:


On Do, 14 Jul 2016, Yegappan Lakshmanan wrote:

> Hi all,
>
> My wish list for extending the Vim search feature:
>
> 1. When searching for a pattern, pressing a key at the search prompt
> should jump to the next or previous match.
> 2. After jumping multiple times from the search prompt, pressing the
> escape key should restore the cursor to the original cursor position
> before the search.
> 3. Pressing backspace at the search prompt to erase a few characters and
> then typing additional characters should start the search from the
> previously matched position and not from the original position.
> 4. As characters are typed at the search prompt, all the matching text
> should be highlighted (multiple matches). This can be turned on/off by
> an option.
>
> I know there are some Vim plugins that support some of these features.
> But it will be useful to extend the built-in Vim feature to support these
> features.

Here is an experimental patch, that does this using Ctrl-N Ctrl-P in
search mode, when 'incsearch' is set. I am not super happy, about
depending on 'incsearch', but on the other hand, Ctrl-L already only
works when 'incsearch' is set. Also I am open to suggestions for
alternative keys, although I must admit, Ctrl-N/Ctrl-P seem like 
logical

choices.

It doesn't do everything you want, but it seems to work well for me. I
made it so, that pressing enter will remain at the current selected
match, which seems obvious and so I did not need to introduce a new 
key

function. Pressing ESC however will return the cursor to the position
where you started with the search.

This was just written very fast, I am pretty sure, there are some bugs
lying around and also tests are missing. But if this turns out to be
useful, I'll work more on it (and add a test of course).

Comments welcome,


This smells like an interactive search dialog.  Does this combine with
the search count?  So when pressing CTRL-N it goes from "match 2 of 23"
to "match 3 of 23"?  And when typing a character it goes to "match 1 of
8"?  (I would think the match index is counting from the original start
position).


You mean the search_stat patch from last week? No, I haven't looked,
how well those two features would work together.

Would it make sense to submit it as one single patch, adding several 
features

at once?

Best,
Christian

--
--
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups "vim_dev" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wish list for a more powerful search in Vim

2016-07-26 Fir de Conversatie Bram Moolenaar

Christian Brabandt wrote:

> On Do, 14 Jul 2016, Yegappan Lakshmanan wrote:
> 
> > Hi all,
> > 
> > My wish list for extending the Vim search feature:
> > 
> > 1. When searching for a pattern, pressing a key at the search prompt
> > should jump to the next or previous match.
> > 2. After jumping multiple times from the search prompt, pressing the
> > escape key should restore the cursor to the original cursor position
> > before the search.
> > 3. Pressing backspace at the search prompt to erase a few characters and
> > then typing additional characters should start the search from the
> > previously matched position and not from the original position.
> > 4. As characters are typed at the search prompt, all the matching text
> > should be highlighted (multiple matches). This can be turned on/off by
> > an option.
> > 
> > I know there are some Vim plugins that support some of these features.
> > But it will be useful to extend the built-in Vim feature to support these
> > features.
> 
> Here is an experimental patch, that does this using Ctrl-N Ctrl-P in 
> search mode, when 'incsearch' is set. I am not super happy, about 
> depending on 'incsearch', but on the other hand, Ctrl-L already only 
> works when 'incsearch' is set. Also I am open to suggestions for 
> alternative keys, although I must admit, Ctrl-N/Ctrl-P seem like logical 
> choices.
> 
> It doesn't do everything you want, but it seems to work well for me. I 
> made it so, that pressing enter will remain at the current selected 
> match, which seems obvious and so I did not need to introduce a new key 
> function. Pressing ESC however will return the cursor to the position 
> where you started with the search.
> 
> This was just written very fast, I am pretty sure, there are some bugs 
> lying around and also tests are missing. But if this turns out to be 
> useful, I'll work more on it (and add a test of course).
> 
> Comments welcome,

This smells like an interactive search dialog.  Does this combine with
the search count?  So when pressing CTRL-N it goes from "match 2 of 23"
to "match 3 of 23"?  And when typing a character it goes to "match 1 of
8"?  (I would think the match index is counting from the original start
position).

-- 
"When I die, I want a tombstone that says "GAME OVER" - Ton Richters

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wish list for a more powerful search in Vim

2016-07-26 Fir de Conversatie Yegappan Lakshmanan
Hi Christian,

On Tue, Jul 26, 2016 at 10:15 AM, Christian Brabandt  wrote:
> Hi Yegappan!
>
> On Do, 14 Jul 2016, Yegappan Lakshmanan wrote:
>
>> Hi all,
>>
>> My wish list for extending the Vim search feature:
>>
>> 1. When searching for a pattern, pressing a key at the search prompt
>> should jump to the next or previous match.
>> 2. After jumping multiple times from the search prompt, pressing the
>> escape key should restore the cursor to the original cursor position
>> before the search.
>> 3. Pressing backspace at the search prompt to erase a few characters and
>> then typing additional characters should start the search from the
>> previously matched position and not from the original position.
>> 4. As characters are typed at the search prompt, all the matching text
>> should be highlighted (multiple matches). This can be turned on/off by
>> an option.
>>
>> I know there are some Vim plugins that support some of these features.
>> But it will be useful to extend the built-in Vim feature to support these
>> features.
>
> Here is an experimental patch, that does this using Ctrl-N Ctrl-P in
> search mode, when 'incsearch' is set. I am not super happy, about
> depending on 'incsearch', but on the other hand, Ctrl-L already only
> works when 'incsearch' is set. Also I am open to suggestions for
> alternative keys, although I must admit, Ctrl-N/Ctrl-P seem like logical
> choices.
>
> It doesn't do everything you want, but it seems to work well for me. I
> made it so, that pressing enter will remain at the current selected
> match, which seems obvious and so I did not need to introduce a new key
> function. Pressing ESC however will return the cursor to the position
> where you started with the search.
>
> This was just written very fast, I am pretty sure, there are some bugs
> lying around and also tests are missing. But if this turns out to be
> useful, I'll work more on it (and add a test of course).
>
> Comments welcome,
>

Thanks for implementing this feature. I am very happy to see this.
I tried the feature and faced the following issues:

1. When pressing CTRL-N or CTRL-P to jump to the next/previous match,
   the 'nowrapscan' setting is ignored and the search wraps around
   the file.
2. After pressing CTRL-N couple of times, erasing the entire search pattern
   and typing a new pattern doesn't search from the original cursor
   position. Instead the search starts from the last matched position.
3. Searching for a pattern, pressing CTRL-N (which doesn't find a
   next match) and then pressing CTRL-L to copy the next character
   from under the cursor doesn't work and also the search highlighting
   is removed.

Regards,
Yegappan

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wish list for a more powerful search in Vim

2016-07-26 Fir de Conversatie Christian Brabandt
Hi Yegappan!

On Do, 14 Jul 2016, Yegappan Lakshmanan wrote:

> Hi all,
> 
> My wish list for extending the Vim search feature:
> 
> 1. When searching for a pattern, pressing a key at the search prompt
> should jump to the next or previous match.
> 2. After jumping multiple times from the search prompt, pressing the
> escape key should restore the cursor to the original cursor position
> before the search.
> 3. Pressing backspace at the search prompt to erase a few characters and
> then typing additional characters should start the search from the
> previously matched position and not from the original position.
> 4. As characters are typed at the search prompt, all the matching text
> should be highlighted (multiple matches). This can be turned on/off by
> an option.
> 
> I know there are some Vim plugins that support some of these features.
> But it will be useful to extend the built-in Vim feature to support these
> features.

Here is an experimental patch, that does this using Ctrl-N Ctrl-P in 
search mode, when 'incsearch' is set. I am not super happy, about 
depending on 'incsearch', but on the other hand, Ctrl-L already only 
works when 'incsearch' is set. Also I am open to suggestions for 
alternative keys, although I must admit, Ctrl-N/Ctrl-P seem like logical 
choices.

It doesn't do everything you want, but it seems to work well for me. I 
made it so, that pressing enter will remain at the current selected 
match, which seems obvious and so I did not need to introduce a new key 
function. Pressing ESC however will return the cursor to the position 
where you started with the search.

This was just written very fast, I am pretty sure, there are some bugs 
lying around and also tests are missing. But if this turns out to be 
useful, I'll work more on it (and add a test of course).

Comments welcome,

Best,
Christian
-- 
Ja, mach nur einen Plan, sei nur ein großes Licht, und mach noch einen
zweiten Plan, gehn tun sie beide nicht.
-- Berthold Brecht (Dreigroschenoper)

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
From ae49fd135effecee212640a5b1e71c56834d49d5 Mon Sep 17 00:00:00 2001
From: Christian Brabandt 
Date: Tue, 26 Jul 2016 11:18:51 +0200
Subject: [PATCH] Make Ctrl-N/P jump to next/previous search match

Currently, you cannot move from one match to the next match
when doing a search '/' or '?'.
This patch adds the functionality to use 'Ctrl-N' to move the
cursor to the next match, if 'insearch' is set. Similarily 'Ctrl-P' will
move to the previous match.

Also c_CTRL-N and c_CTRL-P are already used to move within in history of
search patterns, I have for now made them something different in search
mode, when incsearch is set. This is because c_CTRL-L already does
something useful in search mode and second, because Ctrl-N and
Ctrl-P are already used to select next/previous match in completion mode
so it seems logically to also extend their use in search mode.
---
 runtime/doc/cmdline.txt |  8 +
 src/ex_getln.c  | 77 +++--
 2 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index 8186678..9fbdbd0 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -409,11 +409,19 @@ CTRL-D		List names that match the pattern in front of the cursor.
 			*c_CTRL-N*
 CTRL-N		After using 'wildchar' which got multiple matches, go to next
 		match.  Otherwise recall more recent command-line from history.
+		*/_CTRL-N*
+		When 'incsearch' is set, entering a search pattern for "/" or
+		"?" and the current match is displayed then CTRL-N will move
+		to the next match.
 			*c_CTRL-P* *c_*
 CTRL-P		After using 'wildchar' which got multiple matches, go to
 		previous match.  Otherwise recall older command-line from
 		history.   only works with the GUI, on the Amiga and
 		with MS-DOS.
+		*/_CTRL-P*
+		When 'incsearch' is set, entering a search pattern for "/" or
+		"?" and the current match is displayed then CTRL-N will move
+		to the previous match.
 			*c_CTRL-A*
 CTRL-A		All names that match the pattern in front of the cursor are
 		inserted.
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 642e090..66fd313 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -178,6 +178,8 @@ getcmdline(
 colnr_T	old_curswant;
 colnr_T	old_leftcol;
 linenr_T	old_topline;
+int		did_incs_move = FALSE;
+

Wish list for a more powerful search in Vim

2016-07-14 Fir de Conversatie Yegappan Lakshmanan
Hi all,

My wish list for extending the Vim search feature:

1. When searching for a pattern, pressing a key at the search prompt
should jump to the next or previous match.
2. After jumping multiple times from the search prompt, pressing the
escape key should restore the cursor to the original cursor position
before the search.
3. Pressing backspace at the search prompt to erase a few characters and
then typing additional characters should start the search from the
previously matched position and not from the original position.
4. As characters are typed at the search prompt, all the matching text
should be highlighted (multiple matches). This can be turned on/off by
an option.

I know there are some Vim plugins that support some of these features.
But it will be useful to extend the built-in Vim feature to support these
features.

Thanks,
Yegappan

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.