Friday, November 25, 2011

RE: strip whitespace and carriage returns from end of file

Chris Lott wrote:
> I have the following shortcut to strip whitespace from the
> end of a file:
> nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>

There is a slightly superior mapping at:
http://vim.wikia.com/wiki/Remove_unwanted_spaces

> How can I have that command also strip all trailing
> carriage returns?

You could muck about with a search pattern using \r to match CR,
however it would be better to investigate why there are trailing
CRs. Procedures are discussed at:

http://vim.wikia.com/wiki/File_format

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

No comments: