Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sun-barr!ccut!kogwy!math-keio!mad From: mad@math.keio.ac.jp (MAEDA Atusi) Newsgroups: comp.editors Subject: simple tricks in Vi Message-ID: Date: 28 Jun 90 11:37:33 GMT Sender: news@math.keio.ac.jp Reply-To: tanakat@jpntscvm.bitnet Organization: Faculty of Sci. and Tech., Keio Univ., Yokohama, Japan. Lines: 53 (I am posting this for Tanaka.) ----------------------------------------------------------- Dear People: Encouraged by the positive responses to my last article, I decided to describe some more simple Vi tricks which I have found useful. (1) === moving text between files === If you open two files simultaneously as "vi file1 file2", you can use a named buffer to move text between those files. But this is not how I use Vi; I open one file at a time. So I have these lines in the ".exrc" file: ab wt w! /tmp/temp.vi.tanakat ab rt r /tmp/temp.vi.tanakat I save lines in one file as: :.,.+3 wt (save next 4 lines) :.,'a wt (save up to mark A) and restore these lines in another file by ":rt". (2) === commenting out 1 Lisp expression === (putting semicolons at the beginning of the lines) Place this line in the ".exrc" file: map q mx%my:'x,'ys/^/;/^M`xl ('^M' is a single newline character, not two characters '^' and 'M'.) (3) === reformatting paragraphs within Vi === Place this line in the ".exrc" file: map q !}fmt -61^M (It is better to map this to a function key if your keyboard has one.) I wonder if there are other simple but useful tricks in Vi. (Please send responses, if any, to my BITNET address below.) (Mr.) TANAKA Tomoyuki (Tanaka is my family name.) ;;; IBM Research, Tokyo Research Laboratory ;;; 5-19, Sanbancho, Chiyoda-ku, Tokyo 102, Japan ;;; ;;; BITNET: tanakat@jpntscvm.bitnet ;;; JUNET: tanakat@trl.ibm.co.jp