Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Feb 2009 01:17:36 -0600
From:      Javier Perez <disco299@gmail.com>
To:        Rajarajan Rajamani <r.rajamani@gmail.com>, freebsd-questions@freebsd.org
Subject:   Re: vi set comment #
Message-ID:  <e7b23090902202317g77f53b77v7bc2d2a03cddd936@mail.gmail.com>
In-Reply-To: <4af955a20902200700q21fedab4w764c5f114279052b@mail.gmail.com>
References:  <57200BF94E69E54880C9BB1AF714BBCB5DE58A@w2003s01.double-l.local> <499EC3BE.7020105@polands.org> <4af955a20902200700q21fedab4w764c5f114279052b@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
2009/2/20 Rajarajan Rajamani <r.rajamani@gmail.com>:
> On Fri, Feb 20, 2009 at 9:52 AM, Doug Poland <doug@polands.org> wrote:
>> Johan Hendriks wrote:
>>>
>>> How can i in vi set a # on multiple Lines to comment out some text.
>>>
>>> I know it must be a simple thing but i can not seem to get it right.
>>>
>>> Like in a config file i have the following
>>>
>>> define service{
>>>        use                     generic-service
>>>        host_name               w2003hk03
>>>        service_description     Explorer
>>>        check_command           check_nt!PROCSTATE!-d SHOWALL -l
>>> Explorer.exe
>>>        }
>>>
>>> And now i want to set a # to all the 6 lines.
>>>
>>> Thanks for your time
>>> Regards,
>>> Johan
>>
>>>
>>
>> This question is really more germane to a VIm mail list
>> (http://www.vim.org/) , but I'll tell you how'd I'd do it.
>>
>> First, turn on line numbers --
>>
>>   :set nu
>>
>
>>   :3,8s/^/#/
>>
>> That's all there is too it.  BTW, VIm help is your friend
>>
>
> OR just mark the block visually and then do a
> :'<,'> s:/^/#/
>
> the '<,'> will appear automatically as soon as you hit : after marking
> the visual block.

On vim you can also use a keyboard macro in this way:

1G   (or whatever the line you wanna start from)
qa^i#<esc>jq (the macro itself)
5@a    (as many times you need)


Cheers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?e7b23090902202317g77f53b77v7bc2d2a03cddd936>