Loading ...
Sorry, an error occurred while loading the content.

Re: Path easy-search

Expand Messages
  • Andy Wokula
    ... You re right, but in the first place I wanted /pattern d//e (hit Enter as-needed) to be repeatable with n.n.n.n. Can you suggest a simple mapping which
    Message 1 of 20 , Mar 15, 2013
      Am 20.02.2013 04:45, schrieb ZyX:
      > суббота, 9 апреля 2011 г., 12:53:45 UTC+4 пользователь Andy Wokula написал:
      >> Am 06.04.2011 20:05, schrieb Tim Chase:
      >>> On 04/06/2011 12:50 PM, Christian Brabandt wrote:
      >>>>> ? n n n n searches repeatedly backwards. Then hit N to
      >>>>> search forward, and n to search backward again.
      >>>> I *know* that. Just my fingers...
      >>>> (When I navigate code and jump around a lot, I tend to forget,
      >>>> in which direction I originally searched. I usually only know
      >>>> that I want to move downwards, so I hit 'n' and I hate when
      >>>> Vim moves upwards...)
      >>> And the only thing worse than expecting "n" to move downwards only
      >>> to have it move upwards is having a file that's so similar (such as
      >>> a long tab/CSV file) where you can't readily tell whether you've
      >>> gone up or down :)
      >>> I confess, while Vim has a profusion of options, that's one I
      >>> wouldn't mind seeing...something that toggled between "n means next
      >>> in the same search-direction as last time" and "n means search
      >>> downward in the file". I suppose I could do something like
      >>> :nnoremap n /<cr>
      >>> :nnoremap N ?<cr>
      >>> if it really bugged me that much.
      >> Heh, around 2007 I almost got a headache around this ...
      >> * what's wrong with "n" and "N"
      >> After "d//e" (delete to end of match), "n" (from now on) moves to
      >> the _end_ of the next match, which has become the last search
      >> pattern (not wanted!); also I want "n" to always go forward and
      >> "N" go backward
      >> * Solution:
      >> :no n //<cr>
      >> :no N ??<cr>
      >> Problem: First item in the search history ("/" + "Ctrl-P") now is
      >> "//" and not the last search string, I have to press Ctrl-P again
      >> (annoying, because "//" is useless)
      >> * Solution:
      >> :no <silent> n //<cr>:call histdel('/',-1)<cr>
      >> :no <silent> N ??<cr>:call histdel('/',-1)<cr>
      >> Problem: The current search string is no longer echoed (but with
      >> <silent> omitted, ":call histdel(..." will be echoed, even
      >> worse).
      >> * Solution:
      >> :no <silent> n //<cr>:call histdel('/',-1)<bar>echo '/'.histget('/',-1)<cr>
      >> :no <silent> N ??<cr>:call histdel('/',-1)<bar>echo '/'.histget('/',-1)<cr>
      >> Problem: The message "search hit BOTTOM, continuing at TOP" is
      >> overwritten by the explicit echo.
      >> * Solution:
      >> :no <script> n //<cr><sid>histdel
      >> :no <script> N ??<cr><sid>histdel
      >> :no <silent> <sid>histdel :call histdel('/',-1)<cr>
      >> Problem: Doesn't work for Visual mode. [21-10-2007]
      >> * Solution:
      >> :no <script> n //<cr><sid>histdel
      >> :no <script> N ??<cr><sid>histdel
      >> :nn <silent> <sid>histdel :call histdel('/',-1)<cr>
      >> :vn <silent> <sid>histdel :<c-u>call histdel('/',-1)<cr>gv
      >> Problem: In Visual mode this produces flickering, Command-line
      >> turns Visual mode off when pressing Enter).
      >> * Solution:
      >> :no <script> n //<cr><sid>histdel
      >> :no <script> N ??<cr><sid>histdel
      >> :nn <silent> <sid>histdel :call<sid>histdel(0)<cr>
      >> :vn <silent> <sid>histdel :<c-u>call<sid>histdel(1)<cr>
      >> :func! <sid>histdel(vmode)
      >> : if a:vmode
      >> : normal! gv
      >> : endif
      >> : call histdel('/',-1)
      >> :endfunc
      >> Problem: If cursor is at `> in Visual mode and `< is not on
      >> screen, cursor positioning is like after doing "oo" (flip to `<
      >> and back).
      >> * Solution:
      >> I thought
      >> :vn <silent> <sid>histdel :<c-u>call<sid>histdel(1, line("w0"))<cr>
      >> could help restoring the old position, but it fails. Although
      >> the cursor is at `>, line("w0") always refers to `<, why?
      >> (didn't further investigate here)
      >> What I have now in the vimrc:
      >> ono m //e<CR>
      >> xn <script> m //e<SID>SelOff<CR>
      >> cno <expr> <SID>SelOff &sel=="exclusive" ? "+1" : ""
      >> " do the right thing after o_//e and .
      >> no <script> n //<CR><SID>HistDel
      >> no <script> N ??<CR><SID>HistDel
      >> sunm n|sunm N
      >> nn <silent> <SID>HistDel :call<sid>HistDel(0)<CR>
      >> vn <silent> <SID>HistDel :<C-U>call<sid>HistDel(1)<CR>
      >> ino <silent> <SID>HistDel <C-R>=<sid>HistDel(0)<CR>
      >> func! <sid>HistDel(vmode)
      >> if a:vmode
      >> normal! gv
      >> endif
      >> call histdel('/', -1)
      >> return ""
      >> endfunc
      >> --
      >> Andy
      > Problem: the result is fucking too much code.
      > Solution:
      > noremap <expr> n 'Nn'[v:searchforward]
      > noremap <expr> N 'nN'[v:searchforward]

      You're right, but in the first place I wanted
      (hit Enter as-needed) to be repeatable with

      Can you suggest a simple mapping which supports this?

      Builtin `n' doesn't work, it moves to the end of the next match
      (remembering offset "e").
      `/<CR>' also remembers the offset.
      `//<CR>' moves to start of the next match -- ok, but it leaves a useless
      entry (`/') in the history (to be removed by HistDel() function).

      Actually, I'm fine with the solution -- it worked well for years.


      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

      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    Your message has been successfully submitted and would be delivered to recipients shortly.