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

Path easy-search

Expand Messages
  • giacomo 'giotti' mariani
    Hello everyone, some days ago I was wondering on the best way to search for full *NIX path (something like /path/to/file) in a file. The easier solution, a
    Message 1 of 20 , Apr 6, 2011
    • 0 Attachment
      Hello everyone,
      some days ago I was wondering on the best way to search for full
      *NIX path (something like /path/to/file) in a file. The easier solution,
      a back-slash before each slash, is not that comfortable, especially if
      using the mouse for copy and paste.
      I looked around and summarized my results in:

      http://vim.wikia.com/wiki/Command_for_searching_expressions_%28paths%29_wich_include_backslashes

      but I'm not sure that this is the best way to achieve the desired goal.
      Is there a best way?

      Thanks
      Giacomo

      --
      ##############################################################
      giacomo 'giotti' mariani
      gpg --keyserver pool.sks-keyservers.net --recv-key 0x99bfa859
      O< ASCII ribbon campaign: stop HTML mail
      www.asciiribbon.org
      ##############################################################

      --
      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
    • Christian Brabandt
      ... that link shows me an empty page ( This page needs content... ) ... Simply assign your search string directly to the search-register, e.g. ... and press n
      Message 2 of 20 , Apr 6, 2011
      • 0 Attachment
        On Wed, April 6, 2011 4:11 pm, giacomo 'giotti' mariani wrote:
        > Hello everyone,
        > some days ago I was wondering on the best way to search for full
        > *NIX path (something like /path/to/file) in a file. The easier solution,
        > a back-slash before each slash, is not that comfortable, especially if
        > using the mouse for copy and paste.
        > I looked around and summarized my results in:
        >
        > http://vim.wikia.com/wiki/Command_for_searching_expressions_%28paths%29_wich_include_backslashes

        that link shows me an empty page ("This page needs content...")

        > but I'm not sure that this is the best way to achieve the desired goal.
        > Is there a best way?
        >

        Simply assign your search string directly to the search-register, e.g.
        if you have your search string in the Clipboard, use:
        :let @/=@+
        and press n to jump to the next occurence.

        Of course you can also assign it manually:
        :let @/='/path/with/many/slashes'

        regards,
        Christian

        --
        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
      • Tim Chase
        ... Or you can search backwards with ? : ?/path/to/wherever/with/slashes If you want to change the direction of the search (rather than using the somewhat
        Message 3 of 20 , Apr 6, 2011
        • 0 Attachment
          On 04/06/2011 11:00 AM, Christian Brabandt wrote:
          > Simply assign your search string directly to the search-register, e.g.
          > if you have your search string in the Clipboard, use:
          > :let @/=@+
          > and press n to jump to the next occurence.
          >
          > Of course you can also assign it manually:
          > :let @/='/path/with/many/slashes'

          Or you can search backwards with "?":

          ?/path/to/wherever/with/slashes

          If you want to change the direction of the search (rather than
          using the somewhat awkwardly-inverted n/N commands), you can then
          search forwards with no search criteria which will reuse the
          previous pattern without the need to escape it.

          -tim



          --
          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
        • Christian Brabandt
          ... *g*, when searching backwards, I always get confused, whether to use n/N for my desired direction. Is n keeping the direction or searching forward? And
          Message 4 of 20 , Apr 6, 2011
          • 0 Attachment
            On Wed, April 6, 2011 6:20 pm, Tim Chase wrote:
            > On 04/06/2011 11:00 AM, Christian Brabandt wrote:
            >> Simply assign your search string directly to the search-register, e.g.
            >> if you have your search string in the Clipboard, use:
            >> :let @/=@+
            >> and press n to jump to the next occurence.
            >>
            >> Of course you can also assign it manually:
            >> :let @/='/path/with/many/slashes'
            >
            > Or you can search backwards with "?":
            >
            > ?/path/to/wherever/with/slashes
            >
            > If you want to change the direction of the search (rather than
            > using the somewhat awkwardly-inverted n/N commands), you can then
            > search forwards with no search criteria which will reuse the
            > previous pattern without the need to escape it.
            >

            *g*, when searching backwards, I always get confused, whether to use
            n/N for my desired direction. Is 'n' keeping the direction or searching
            forward? And if 'N' reverses the direction and ? also reverses the
            direction this reverses twice? That is too confusing for me...

            So I try to avoid ?-search and jump to a place from which I can search
            forward.

            regards,
            Christian

            --
            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
          • Tim Chase
            ... while it took me a while to figure it out (and remember it), it still doesn t feel totally natural to think that n means keep searching in the same
            Message 5 of 20 , Apr 6, 2011
            • 0 Attachment
              On 04/06/2011 11:34 AM, Christian Brabandt wrote:
              > *g*, when searching backwards, I always get confused, whether
              > to use n/N for my desired direction. Is 'n' keeping the
              > direction or searching forward? And if 'N' reverses the
              > direction and ? also reverses the direction this reverses
              > twice? That is too confusing for me...

              while it took me a while to figure it out (and remember it), it
              still doesn't feel totally natural to think that "n" means "keep
              searching in the same direction as my last search, whatever that
              was", so unless I've JUST done a backwards "?" search, I find it
              a bit cumbersome and side with you. Though sometimes setting
              'nowrapscan' helps me keep them straight because I can then tell
              when I hit the top/bottom of the file.

              -tim




              --
              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
            • Tony Mechelynck
              ... ? n n n n searches repeatedly backwards. Then hit N to search forward, and n to search backward again. Best regards, Tony. -- Death is nature s way of
              Message 6 of 20 , Apr 6, 2011
              • 0 Attachment
                On 06/04/11 18:34, Christian Brabandt wrote:
                > On Wed, April 6, 2011 6:20 pm, Tim Chase wrote:
                >> On 04/06/2011 11:00 AM, Christian Brabandt wrote:
                >>> Simply assign your search string directly to the search-register, e.g.
                >>> if you have your search string in the Clipboard, use:
                >>> :let @/=@+
                >>> and press n to jump to the next occurence.
                >>>
                >>> Of course you can also assign it manually:
                >>> :let @/='/path/with/many/slashes'
                >>
                >> Or you can search backwards with "?":
                >>
                >> ?/path/to/wherever/with/slashes
                >>
                >> If you want to change the direction of the search (rather than
                >> using the somewhat awkwardly-inverted n/N commands), you can then
                >> search forwards with no search criteria which will reuse the
                >> previous pattern without the need to escape it.
                >>
                >
                > *g*, when searching backwards, I always get confused, whether to use
                > n/N for my desired direction. Is 'n' keeping the direction or searching
                > forward? And if 'N' reverses the direction and ? also reverses the
                > direction this reverses twice? That is too confusing for me...
                >
                > So I try to avoid ?-search and jump to a place from which I can search
                > forward.
                >
                > regards,
                > Christian
                >

                ? n n n n searches repeatedly backwards. Then hit N to search forward,
                and n to search backward again.


                Best regards,
                Tony.
                --
                "Death is nature's way of saying `Howdy'".

                --
                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
              • Christian Brabandt
                Hi Tony! ... 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
                Message 7 of 20 , Apr 6, 2011
                • 0 Attachment
                  Hi Tony!

                  On Mi, 06 Apr 2011, Tony Mechelynck 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...)

                  That's why I try to avoid the ? search.

                  regards,
                  Christian
                  --
                  Das Leben ist kurz, und es wird im Jenseits keiner nach der Zahl der
                  Bücher gefragt, die er bewältigt hat. Darum ist es unklug und
                  schädlich, mit wertloser Lektüre Zeit hinzubringen.
                  -- Hermann Hesse (Über das Leben)

                  --
                  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
                • Tim Chase
                  ... 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)
                  Message 8 of 20 , Apr 6, 2011
                  • 0 Attachment
                    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.

                    -tim


                    --
                    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
                  • Christian Brabandt
                    Hi Tim! ... Oh yes, I know that... regards, Christian -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text
                    Message 9 of 20 , Apr 6, 2011
                    • 0 Attachment
                      Hi Tim!

                      On Mi, 06 Apr 2011, Tim Chase wrote:

                      > 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 :)

                      Oh yes, I know that...

                      regards,
                      Christian

                      --
                      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
                    • John Beckett
                      ... For the record, the actual title has a dot ( . ) at the end:
                      Message 10 of 20 , Apr 6, 2011
                      • 0 Attachment
                        giacomo wrote:
                        > some days ago I was wondering on the best way to search
                        > for full *NIX path (something like /path/to/file) in a file.
                        > The easier solution, a back-slash before each slash, is not
                        > that comfortable, especially if using the mouse for copy and paste.
                        > I looked around and summarized my results in:
                        >
                        > http://vim.wikia.com/wiki/Command_for_searching_expressions_%28paths%29_wich_include_backslashes

                        For the record, the actual title has a dot ('.') at the end:

                        http://vim.wikia.com/wiki/Command_for_searching_expressions_%28paths%29_wich_include_backslashes.

                        I have put the information discussed here into the comments in
                        the tip and will clean it up later.

                        John

                        --
                        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
                      • John Little
                        ... That url lacks a trailing period: http://vim.wikia.com/wiki/Command_for_searching_expressions_%28paths%29_wich_include_backslashes. Regards, John -- You
                        Message 11 of 20 , Apr 6, 2011
                        • 0 Attachment
                          > >http://vim.wikia.com/wiki/Command_for_searching_expressions_%28paths%...
                          >
                          > that link shows me an empty page ("This page needs content...")

                          That url lacks a trailing period:

                          http://vim.wikia.com/wiki/Command_for_searching_expressions_%28paths%29_wich_include_backslashes.

                          Regards, John

                          --
                          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
                        • Tony Mechelynck
                          ... Hm, apparently my mailer did not include the period in the link. The following should work:
                          Message 12 of 20 , Apr 6, 2011
                          • 0 Attachment
                            On 07/04/11 03:34, John Little wrote:
                            >
                            >>> http://vim.wikia.com/wiki/Command_for_searching_expressions_%28paths%...
                            >>
                            >> that link shows me an empty page ("This page needs content...")
                            >
                            > That url lacks a trailing period:
                            >
                            > http://vim.wikia.com/wiki/Command_for_searching_expressions_%28paths%29_wich_include_backslashes.
                            >
                            > Regards, John
                            >

                            Hm, apparently my mailer did not include the period in the link. The
                            following should work:
                            http://vim.wikia.com/wiki/Command_for_searching_expressions_%28paths%29_wich_include_backslashes%2E

                            Also, maybe that wiki page needs a rename or a redirect.


                            Best regards,
                            Tony.
                            --
                            It is against the law for a monster to enter the corporate limits of
                            Urbana, Illinois.

                            --
                            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
                          • Ben Schmidt
                            ... That is going straight into my .vimrc. One of those things that annoys me, but not enough for me to bother doing anything about it. But if someone s going
                            Message 13 of 20 , Apr 6, 2011
                            • 0 Attachment
                              > I suppose I could do something like
                              >
                              > :nnoremap n /<cr>
                              > :nnoremap N ?<cr>
                              >
                              > if it really bugged me that much.

                              That is going straight into my .vimrc. One of those things that annoys
                              me, but not enough for me to bother doing anything about it. But if
                              someone's going to hand me a solution on a plate. :-)

                              (I guess it's similar to the J-is-not-an-operator thing, which I
                              recently addressed when something pushed me over the line!).

                              Smiles,

                              Ben.



                              --
                              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
                            • eNG1Ne
                              From a technical writer s stand-point, the title of an article should not have a final full-stop: it isn t a sentence. Also, remember to spell-check: wich is
                              Message 14 of 20 , Apr 7, 2011
                              • 0 Attachment
                                From a technical writer's stand-point, the title of an article should
                                not have a final full-stop: it isn't a sentence. Also, remember to
                                spell-check: "wich" is a typo <g>

                                On Apr 7, 6:30 am, Tony Mechelynck <antoine.mechely...@...>
                                wrote:
                                > On 07/04/11 03:34, John Little wrote:
                                >
                                >
                                >
                                > >>>http://vim.wikia.com/wiki/Command_for_searching_expressions_%28paths%...
                                >
                                > >> that link shows me an empty page ("This page needs content...")
                                >
                                > > That url lacks a trailing period:
                                >
                                > >http://vim.wikia.com/wiki/Command_for_searching_expressions_%28paths%....
                                >
                                > > Regards, John
                                >
                                > Hm, apparently my mailer did not include the period in the link. The
                                > following should work:http://vim.wikia.com/wiki/Command_for_searching_expressions_%28paths%...
                                >
                                > Also, maybe that wiki page needs a rename or a redirect.
                                >
                                > Best regards,
                                > Tony.
                                > --
                                > It is against the law for a monster to enter the corporate limits of
                                > Urbana, Illinois.

                                --
                                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
                              • Andy Wokula
                                ... 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
                                Message 15 of 20 , Apr 9, 2011
                                • 0 Attachment
                                  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

                                  --
                                  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
                                • Ben Schmidt
                                  ... [...] ... Thanks! I ll give it a try! Ben. -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you
                                  Message 16 of 20 , Apr 10, 2011
                                  • 0 Attachment
                                    > Heh, around 2007 I almost got a headache around this ...
                                    [...]
                                    > 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

                                    Thanks! I'll give it a try!
                                    Ben.



                                    --
                                    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
                                  • Ben Schmidt
                                    ... Problem: Folds are not automatically opened any more Solution: Add a zv command when search is in foldopen no n
                                    Message 17 of 20 , May 1, 2011
                                    • 0 Attachment
                                      > * what's wrong with "n" and "N"
                                      ...
                                      > 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

                                      Problem: Folds are not automatically opened any more
                                      Solution: Add a zv command when "search" is in 'foldopen'

                                      no <script> <expr> n "//<CR>".(&fdo=~"search"?"zv":"")."<SID>HistDel"
                                      no <script> <expr> N "??<CR>".(&fdo=~"search"?"zv":"")."<SID>HistDel"

                                      (The rest is unchanged.)

                                      Ben.



                                      --
                                      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
                                    • Andy Wokula
                                      ... He, thanks, that s right. But I d use another script mapping to add the zv; for example, at the moment, one can t do (Insert mode) Ctrl-O n ono m //e
                                      Message 18 of 20 , May 2, 2011
                                      • 0 Attachment
                                        Am 02.05.2011 04:04, schrieb Ben Schmidt:
                                        >> * what's wrong with "n" and "N"
                                        > ...
                                        >> 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
                                        >
                                        > Problem: Folds are not automatically opened any more
                                        > Solution: Add a zv command when "search" is in 'foldopen'
                                        >
                                        > no <script> <expr> n "//<CR>".(&fdo=~"search"?"zv":"")."<SID>HistDel"
                                        > no <script> <expr> N "??<CR>".(&fdo=~"search"?"zv":"")."<SID>HistDel"

                                        He, thanks, that's right.
                                        But I'd use another script mapping to add the zv; for example, at the
                                        moment, one can't do
                                        (Insert mode) Ctrl-O n


                                        ono m //e<CR>
                                        xn <script> m //e<SID>SelOff<CR>

                                        cno <expr> <SID>SelOff &sel=="exclusive" ? "+1" : ""

                                        no <script> n //<CR><SID>zv<SID>HistDel
                                        no <script> N ??<CR><SID>zv<SID>HistDel
                                        sunm n|sunm N

                                        no <expr> <SID>zv &fdo=~"search" ? "zv" : ""
                                        imap <SID>zv <Nop>

                                        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

                                        --
                                        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
                                      • ZyX
                                        ... Problem: the result is fucking too much code. Solution: noremap n Nn [v:searchforward] noremap N nN [v:searchforward] -- -- You received
                                        Message 19 of 20 , Feb 19, 2013
                                        • 0 Attachment
                                          суббота, 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 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.
                                        • 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 20 of 20 , Mar 15, 2013
                                          • 0 Attachment
                                            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
                                            /pattern
                                            d//e
                                            (hit Enter as-needed) to be repeatable with
                                            n.n.n.n.

                                            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.

                                            --
                                            Andy

                                            --
                                            --
                                            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.