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

Re: Substitution gets broken when mapped

Expand Messages
  • Tim Chase
    ... I too thought about the /e flag about 2 seconds after I pushed :-) I m curious if there was a reason you didn t use getpos()/setpos() (which takes
    Message 1 of 5 , May 12 1:50 PM
    • 0 Attachment
      On 2013-05-12 15:36, tooth pik wrote:
      > let mapleader = ','
      > nnoremap <Leader>a :call StripTrailingWhitespace()<CR>
      > function! StripTrailingWhitespace()
      > let _s=@/
      > let l = line(".")
      > let c = col(".")
      > %s/\s\+$//e
      > let @/=_s
      > call cursor(l, c)
      > endfunction

      I too thought about the /e flag about 2 seconds after I pushed
      <send> :-)

      I'm curious if there was a reason you didn't use getpos()/setpos()
      (which takes care of some peculiar edge cases regarding
      'virtualedit') or make the saved-search local?

      let l:saved_search=@/
      let l:oldpos = getpos()
      %s/\s\+$//e
      setpos('.', l:oldpos)
      let @/=l:saved_search

      -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

      ---
      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.
    • Sylvia Ganush
      ... But of course: I had w tied also to another mapping. I changed the mapping and all works as expected now. Thank you, Tim and Tooth Pik. Sylvia --
      Message 2 of 5 , May 12 2:01 PM
      • 0 Attachment
        On 12 May 2013, at 22:36, tooth pik <toothpik6@...> wrote:

        > I'd start by checking mappings as Tim suggested...

        But of course: I had <leader>w tied also to another mapping. I changed the mapping
        and all works as expected now.

        Thank you, Tim and Tooth Pik.

        Sylvia

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