[ubuntu-uk] Advanced vi/vim command - commenting out a large section
kirrus at kirrus.co.uk
Wed Aug 20 12:25:46 BST 2008
-----BEGIN PGP SIGNED MESSAGE-----
>> It's a little bit hacky, but the way I do that is to do a substitute with the
>> 'start of line' token in the regexp. That way you can use a standard vim range
>> e.g. 1,10 to do lines 1 to 11
> EDIT: I forgot, if you want to do a range from the current cursor position you
> can do it as '.,+x' where x is the number of lines after the one you're on.
> e.g. ':.,+4s/^/# /' would comment out the line you're on and the four after it.
Thanks for all the suggestions!
I'll try them out next time I have to comment out some stuff :)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the ubuntu-uk