On Mo, 18 Feb 2019, Jason Franklin wrote:
> Greetings,
>
> Trying to figure out if this is intentional or not. It is definitely
> surprising given how the documentation (":h gn") is written.
>
> Take the following text as an example.
>
> > Word
> >
> >
> > WORD
> >
> >
> > WORD
> >
> >
> > Word
>
> To reproduce:
>
> 1. set ic scs
> 2. gg*gg
> 3. gn (observe selection is correct)
> 4. <Esc>j
> 5. gn (observe selection is NOT as expected)
>
> So, gn/gN don't use 'smartcase' in the same way that 'n/N' do.
Well, * is a special case and does intentionally ignore the smartcase
setting. I am not sure it is easily possible to ignore the smartcase
setting for gn, when the original search pattern came from * or # command
> This is only one of the problems I observe here. Another has to do with
> direction. When you search backward with "?word", using "n" will move forward
> in the most recently used direction (i.e., backward in the file). "gn" ALWAYS
> moves forward. Thus, it is not similar to "n". This same thing occurs when
> you use the "#" command to search backward.
That was intentionally made that way, because I considered the switching
of directions for n/N depending on the original search command one of my
biggest personal annoyances. So I decided not to obey it for gn. Perhaps
a doc patch like this is appropriate?
diff --git a/runtime/doc/visual.txt b/runtime/doc/visual.txt
index 0b8ca99cd..2d04c89fe 100644
--- a/runtime/doc/visual.txt
+++ b/runtime/doc/visual.txt
@@ -118,6 +118,8 @@ gn Search forward for the last used search
pattern, like
E.g., "dgn" deletes the text of the next match.
If Visual mode is active, extends the selection
until the end of the next match.
+ Note: search direction does not depend on the previous
+ search command.
*gN* *v_gN*
gN Like |gn| but searches backward, like with `N`.
Best,
Christian
--
Es gibt keine Leute, die nichts erleben, es gibt nur Leute, die nichts
davon merken.
-- Curt Goetz
--
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.