vi set comment #

Rajarajan Rajamani r.rajamani at gmail.com
Fri Feb 20 07:31:44 PST 2009


On Fri, Feb 20, 2009 at 9:52 AM, Doug Poland <doug at 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.


More information about the freebsd-questions mailing list