Tuesday, November 1, 2011

Re: function to apply multiple whole-file substitutions

On 2011-11-01, eda wizard wrote:

> function Scrub ()
> :%s// /g
> :%s/\s*$//g
> endfunction
> map :call Scrub ()

> Hm, somehow things got left out of my post:
>
> first substitution is to replace every TAB character in the file
> with two spaces.

%s/\t/ /g

A leading colon is OK but not necessary. See

:help 41.1

In a Vim regular expression, a tab can be represented as \t. See

:help /\t

Depending on why and how you want to replace tabs by spaces, you may
want to take a look at

:help :retab
:help 'expandtab'

> second substitution is to match lines containing only whitespace
> characters and remove all said characters leaving only empty
> lines.

%s/^\s\+$//

See

:help /^
:help /\+

Regards,
Gary

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