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

Delete from search history

Expand Messages
  • Dimitar DIMITROV
    Hi, The call to histdel below doesn t seem to be doing what I want it to do. It doesn t delete my 3 search patterns added by the 2 :substitute and the :global
    Message 1 of 3 , Sep 27, 2013
    • 0 Attachment
      Hi,
      The call to histdel below doesn't seem to be doing what I want it to do.
      It doesn't delete my 3 search patterns added by the 2 :substitute and the :global calls.
      Not sure what it does exactly, it seems to delete one correct entry and 2 wrong ones.
      All I want is no trace of those patterns in my search history,
      but histdel('/', '\\s\\+\$') wouldn't be a solution since I still want this pattern in my history if I enter it manually at some point.
      Any help appreciated.

      " Squeeze empty lines
      function! s:Squeeze()
         let save_cursor = getpos(".")
         " empty lines at BOF|EOF
         silent  %substitute/\%^\_s*\n\|\_s*\%$//
         " empty line clusters
         silent   global/^\%(\s*$\n\)\{2,}/delete
         silent! %substitute/\s\+$//e
         for i in range(1, 3)
            call histdel('/', -1)
         endfor
         call setpos('.', save_cursor)
      endfunction

      nmap <silent> <leader>z :call <sid>Squeeze()<cr>

      Regards
       
      Dimitar

      ---
      GPG Key: 2048R/160C6FA8 2012-10-11 Dimitar Dimitrov (kurkale6ka) <mitkofr@...>

      --
      --
      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.
    • Bram Moolenaar
      ... Not sure what happens there, but it might be a lot simpler if we have a way to avoid patterns to be put in the history, instead of deleting them
      Message 2 of 3 , Sep 28, 2013
      • 0 Attachment
        Dimitar Dimitrov wrote:

        > Hi,
        > The call to histdel below doesn't seem to be doing what I want it to do.
        > It doesn't delete my 3 search patterns added by the 2 :substitute and
        > the :global calls. Not sure what it does exactly, it seems to delete
        > one correct entry and 2 wrong ones.
        > All I want is no trace of those patterns in my search history,
        > but histdel('/', '\\s\\+\$') wouldn't be a solution since I still want
        > this pattern in my history if I enter it manually at some point.
        > Any help appreciated.
        >
        >
        > " Squeeze empty lines
        > function! s:Squeeze()
        >    let save_cursor = getpos(".")
        >    " empty lines at BOF|EOF
        >   
        > silent  %substitute/\%^\_s*\n\|\_s*\%$//
        >    " empty line clusters
        >    silent   global/^\%(\s*$\n\)\{2,}/delete
        >    silent! %substitute/\s\+$//e
        >    for i in range(1, 3)
        >       call histdel('/', -1)
        >    endfor
        >    call setpos('.', save_cursor)
        > endfunction
        >
        > nmap <silent> <leader>z :call <sid>Squeeze()<cr>

        Not sure what happens there, but it might be a lot simpler if we have a
        way to avoid patterns to be put in the history, instead of deleting them
        afterwards. When a pattern was typed you may want to keep it, but after
        executing a :s command you don't know if the pattern was typed before
        you used it with :s. That gets complicated.

        For :s we could add a flag, but for :g/pattern/ there is is no place to
        put a flag. Perhaps we should use a modifier ":keeppatterns", like
        ":keepjumps" and ":keepmarks" ?

        --
        ### Hiroshima 45, Chernobyl 86, Windows 95 ###

        /// Bram Moolenaar -- Bram@... -- 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_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.
      • Dimitar DIMITROV
        ... Yes that would be perfect. In fact I spent quite a lot of time searching the help thinking there would be something like that. Also the help at line 67 in
        Message 3 of 3 , Sep 28, 2013
        • 0 Attachment
          >> Hi,
          >> The call to histdel below doesn't seem to be doing what I want it to do.
          >> It doesn't delete my 3 search patterns added by the 2 :substitute and
          >> the :global calls.  Not sure what it does exactly, it seems to delete
          >> one correct entry and 2 wrong ones.
          >> All I want is no trace of those patterns in my search history,
          >> but histdel('/', '\\s\\+\$') wouldn't be a solution since I still want
          >> this pattern in my history if I enter it manually at some point.
          >> Any help appreciated.
          >>
          >>
          >> " Squeeze empty lines
          >> function! s:Squeeze()
          >>    let save_cursor = getpos(".")
          >>    " empty lines at BOF|EOF
          >>  
          >> 
          silent  %substitute/\%^\_s*\n\|\_s*\%$//
          >>    " empty line clusters
          >>    silent   global/^\%(\s*$\n\)\{2,}/delete
          >>    silent! %substitute/\s\+$//e
          >>    for i in range(1, 3)
          >>       call histdel('/', -1)
          >>    endfor
          >>    call setpos('.', save_cursor)
          >> endfunction
          >>
          >> nmap <silent> <leader>z :call <sid>Squeeze()<cr>
          >
          >Not sure what happens there, but it might be a lot simpler if we have a
          >way to avoid patterns to be put in the history, instead of deleting them
          >afterwards.  When a pattern was typed you may want to keep it, but after
          >executing a :s command you don't know if the pattern was typed before
          >you used it with :s.  That gets
          complicated.
          >
          >For :s we could add a flag, but for :g/pattern/ there is is no place to
          >put a flag.  Perhaps we should use a modifier ":keeppatterns", like
          >":keepjumps" and ":keepmarks" ?

          Yes that would be perfect. In fact I spent quite a lot of time searching the
          help thinking there would be something like that.
          Also the help at line 67 in cmdline.txt might need changing as it implies only
          one search pattern would be remembered if coming from a mapping. Not all of them
          as it happens in this example.

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