From owner-freebsd-questions@FreeBSD.ORG Sat Feb 21 07:48:48 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 00DEB106564A for ; Sat, 21 Feb 2009 07:48:48 +0000 (UTC) (envelope-from disco299@gmail.com) Received: from mail-qy0-f12.google.com (mail-qy0-f12.google.com [209.85.221.12]) by mx1.freebsd.org (Postfix) with ESMTP id 1E9408FC0C for ; Sat, 21 Feb 2009 07:48:47 +0000 (UTC) (envelope-from disco299@gmail.com) Received: by qyk5 with SMTP id 5so2642132qyk.19 for ; Fri, 20 Feb 2009 23:48:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=l7Q4tGqObeZjCVbQL+qICBuBtGQioPCOCu9Ui0/vN8Q=; b=RlZVpNx0ORciFHfXoPL6ax2Ov9RJbol5tmI6P9ZRZmCpZfE34z2p8AcgWT6xtqvNS0 6pTjgx7YLbBr2gmtSFhEhryPFXLT2GUkeulzUX62TZ57bnBDvDtZDrEGFruTzq467YNK BRV0659X6eDrUW6C3ycnceXxpB+fL7lEEOIec= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=TD8CnhZ2rDBg11wEG5TJsepqbylI1bJHbL81mrUUAnASerDKx+CLLwNwbpkdy+nhef UA0+ReGICSx7fbYKzzml1jnDE/uDcqL/mS4IF4DVBvwIwGQDOnSQtYUdQ1c++JiduE5N 2Dtthy3CoTW0IRTdZ8jmJ7Jjo311J9y0lxvAk= MIME-Version: 1.0 Received: by 10.224.6.83 with SMTP id 19mr2787941qay.208.1235200656044; Fri, 20 Feb 2009 23:17:36 -0800 (PST) In-Reply-To: <4af955a20902200700q21fedab4w764c5f114279052b@mail.gmail.com> References: <57200BF94E69E54880C9BB1AF714BBCB5DE58A@w2003s01.double-l.local> <499EC3BE.7020105@polands.org> <4af955a20902200700q21fedab4w764c5f114279052b@mail.gmail.com> Date: Sat, 21 Feb 2009 01:17:36 -0600 Message-ID: From: Javier Perez To: Rajarajan Rajamani , freebsd-questions@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Subject: Re: vi set comment # X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Feb 2009 07:48:48 -0000 2009/2/20 Rajarajan Rajamani : > On Fri, Feb 20, 2009 at 9:52 AM, Doug Poland 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#jq (the macro itself) 5@a (as many times you need) Cheers.