Friday, December 25, 2015

Re: New in VIM

Even ^#\~ works for me: the # doesn't need backslash-escaping

Let's say (assuming # is the start-comment delimiter)

function Comment() range
exe a:firstline ',' a:lastline 's/^\ze\~/#/'
endfunction

function Uncomment() range
exe a:firstline ',' a:lastline 's/^#\ze\~//'
endfunction

Then use these functions by using the :call command with a range (or
from Visual mode, which will pass '<,'> as the range to execute the
function on the selected lines). For the whole file, use :%call or
:1,$call

See
:help /~
:help /\
:help /\ze
:help :func-range
:help :call
:help v_:
:help :range


Best regards,
Tony.

On Sat, Dec 26, 2015 at 5:54 AM, Paolo Bolzoni
<paolo.bolzoni.brown@gmail.com> wrote:
> ^\#\~ works fine to me, what is the problem?
>
> On Sat, Dec 26, 2015 at 4:39 AM, janc@telefonica.net
> <janc@telefonica.net> wrote:
>> Hi! all.
>>
>> I am almost newbie about VIM and every day I like it more and more.
>>
>> I am try to make a function to comment/uncomment lines with "#~ " at ^ of line.
>>
>> But I can not find the regex to search "#~ " at ^ of line, I think I have tried
>> almost every posibilities.
>>
>> Can you help me? Thank in advanced.
>>
>> --
>> Jose Angel Navarro Cortes
>> email: janc@telefonica.net
>> web: http://janc.es/
>> Usuario Linux: #49178
>>
>> --
>> --
>> 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/d/optout.
>
> --
> --
> 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/d/optout.

--
--
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/d/optout.

No comments: