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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to