Re: search next, prev while in /pattern editing
On Thu, 18 May 2006, Eric Arnold wrote: On 5/18/06, Eric Arnold <[EMAIL PROTECTED]> wrote: I think this does what you want. You only need to use "/", though, since you can now go up and down while in "/" : cmap N:redraw/ cmap n:redraw/ Rats. This works only if you set the @/ variable first by hitting return normally, which will highlight the pattern, then subsequence ^X or ^Y will move to the right pattern. Benji's simple example has the same problem if you start with These come close, but the first time you use them, they do something slightly different than subsequent times. ^R go up *2* matches, and ^S just goes to what looks like the current match (i.e. it doesn't appear to move). It's all a problem of where the cursor actually is v.s. where the highlighting is for incsearch. cmap NN:redraw/ cmap :redraw/ I have set incsearch hlsearch and so I use this: cmap :noh/ cmap :noh? The only (unavoidable) downside to this is that it expects the cursor to be at the start of the searched item after the first . However, there's no way to be sure of that. Hence, any use of "n" and "N" (Normal mode) in the mappings will throw the search off by one, two, etc. I also have to be careful not to hit or while I'm typing an :Ex command. HTH :) -- Gerald
Re: search next, prev while in /pattern editing
On Thu, 18 May 2006 at 9:31am, Benji Fisher wrote: > On Thu, May 18, 2006 at 12:27:26PM +, Yakov Lerner wrote: > > I am using incsearch. I wanted to define 2 mappings that > > act while I am in /search pattern editing mode, > > and that take me to next/prev match > > while leaving the cursor in /pattern commandline. > > Is it possible ? > > > > Yakov > > If you only use / and not ? then > > :cmap / > :cmap N/ > > should work. If you want it to work with both / and ?, you have to work > a little harder. Try this: > > cmap =Next()Next > fun! Next() > if getcmdtype() == "/" > cmap Next / > elseif getcmdtype() == "?" > cmap Next NN? > else > cmap Next > endif > return "" > endfun > > The other direction is left as an exercise. > > HTH --Benji Fisher > The problem with this approach is that you can't cancel out of the search prompt and expect to be back at the original cursor position. Also, is now lost for other modes, though you can fix that problem using the new map (see below), but may I first suggest you try my chcmdmode.vim plugin? I have the ^S at search prompt to do just this, and I have a few more maps that could be useful for you too. Now, back to improving what Benji suggested: cmap Next() fun! Next() if getcmdtype() == "/" return "\/\" elseif getcmdtype() == "?" return "\NN?\" else return "\" endif endfun You see, there is no temporary mapping involved, and you still didn't loose for other modes. -- HTH, Hari __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Re: search next, prev while in /pattern editing
On 5/18/06, Eric Arnold <[EMAIL PROTECTED]> wrote: On 5/18/06, Eric Arnold <[EMAIL PROTECTED]> wrote: > I think this does what you want. You only need to use "/", though, > since you can now go up and down while in "/" : > > cmap N:redraw/ > cmap n:redraw/ Thanks to everybody who responded. Yakov
Re: search next, prev while in /pattern editing
On 5/18/06, Eric Arnold <[EMAIL PROTECTED]> wrote: I think this does what you want. You only need to use "/", though, since you can now go up and down while in "/" : cmap N:redraw/ cmap n:redraw/ Rats. This works only if you set the @/ variable first by hitting return normally, which will highlight the pattern, then subsequence ^X or ^Y will move to the right pattern. Benji's simple example has the same problem if you start with These come close, but the first time you use them, they do something slightly different than subsequent times. ^R go up *2* matches, and ^S just goes to what looks like the current match (i.e. it doesn't appear to move). It's all a problem of where the cursor actually is v.s. where the highlighting is for incsearch. cmap NN:redraw/ cmap :redraw/
Re: search next, prev while in /pattern editing
I think this does what you want. You only need to use "/", though, since you can now go up and down while in "/" : cmap N:redraw/ cmap n:redraw/
Re: search next, prev while in /pattern editing
On Thu, May 18, 2006 at 12:27:26PM +, Yakov Lerner wrote: > I am using incsearch. I wanted to define 2 mappings that > act while I am in /search pattern editing mode, > and that take me to next/prev match > while leaving the cursor in /pattern commandline. > Is it possible ? > > Yakov If you only use / and not ? then :cmap / :cmap N/ should work. If you want it to work with both / and ?, you have to work a little harder. Try this: cmap =Next()Next fun! Next() if getcmdtype() == "/" cmap Next / elseif getcmdtype() == "?" cmap Next NN? else cmap Next endif return "" endfun The other direction is left as an exercise. HTH --Benji Fisher
Re: search next, prev while in /pattern editing
cmap n/ On 5/18/06, Yakov Lerner <[EMAIL PROTECTED]> wrote: I am using incsearch. I wanted to define 2 mappings that act while I am in /search pattern editing mode, and that take me to next/prev match while leaving the cursor in /pattern commandline. Is it possible ? Yakov