On 14/10/08 15:03, Teemu Likonen wrote:
> [2008-10-14 05:44 -0700] fritzophrenic wrote:
>
>> On Oct 14, 3:54 am, Teemu Likonen<[EMAIL PROTECTED]>  wrote:
>>>      vipc
>> Or how about dip instead, saving 2 keystrokes (unless you _want_ to be
>> in insert mode after you delete the lines).
>
> We wanted to leave one empty line and "vipc" or "cip" does that; "dip"
> deletes all so we would need "O" to open a new line, which in turn puts
> us to insert mode too. We have to choose:
>
>      vipc
>      cip
>      dipO
>      vipdO
>
> But...
>
>>>      map<C-x><C-o>  :if getline('.') =~ '^\s*$'<bar>
>>>          \ execute 'normal! vipc'<bar>  endif<CR>
>
> ...since we run the normal mode commands with :execute we don't end up
> in insert mode.
>
>> Note the use of =~ to match a regular expression, and the use of '\s'
>> inside the regular expression to match _any_ whitespace, and not just
>> spaces and tabs like some previous patterns.
>
> Apart from spaces and tabs, what are those other whitespaces that \s
> matches?

        :%g/^\s*$/d

deletes any lines consisting of any mixture of zero or more spaces 
and/or tabs

        :%g/^\t*$/d

deletes any lines consisting only of zero or more tabs

        :%g/^ *$/

deletes any lines consisting only of zero or more spaces

The advantage of \s* is that it matches _any mixture_ of spaces and 
tabs, not just only the one or only the other.


Best regards,
Tony.
-- 
Anyone who cannot cope with mathematics is not fully human.  At best he
is a tolerable subhuman who has learned to wear shoes, bathe and not
make messes in the house.
                -- Lazarus Long, "Time Enough for Love"

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to