Sunday, May 12, 2013

Substitution gets broken when mapped

Hello.

I'm lost: one same substitution command works fine if executed from the
command line, but gets broken if executed via a mapping.

To remove trailing spaces I do:

:%s/\s\+$//

And it works perfectly. Since it's such a useful command I add this
mapping to my .vimrc:

nmap <leader>w :%s/\s\+$// <cr>

But when I use the mapping, many extra lines get deleted and the text is
mangled.

I expect the mapping to yield the same result as the direct command, but
it doesn't. What gives?

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@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: