Date: Sat, 11 Feb 2006 12:27:25 -0800 From: Bill Campbell <freebsd@celestial.com> To: questions@freebsd.org Subject: Re: formatting text from within vi Message-ID: <20060211202725.GA2679@alexis.mi.celestial.com> In-Reply-To: <20060211184600.GA85555@skytracker.ca> References: <20060211184600.GA85555@skytracker.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Feb 11, 2006, David Banning wrote: >I am familiar with the !}fmt used in vi to reformat a paragraph, but >I wondered how, or if it is possible to do more complex formatting. You can format any line or block of text in vi(m) by passing it through an arbitrary filter program. I have this line in my ~/.vimrc file which formats whatever paragraph the cursor is in by running through a script I wrote that formats its standard using ``groff -mm''. The ``{'' positions the cursor at the beginning of the paragraph and the ``!}'' says filter to the end of the paragraph. map <F5> {!}gfmt You can also type a command on a line, and execute it replacing the contents of the line with the output of the program. If I want to get copies of all my signature files containing the text ``democracy'' I could enter the following line, place the cursor somplace in that line, and press ``!!sh<RETURN>''. cat `grep -li democracy ~/.signature.*` Bill -- INTERNET: bill@Celestial.COM Bill Campbell; Celestial Software LLC URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676 Those who profess to favor freedom, and yet depreciate agitation, are men who want rain without thunder and lightning. They want the ocean without the roar of its many waters. -- Frederick Douglass
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060211202725.GA2679>